Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {API_KEY} from './../APIkey';
- export const FETCHING_USER = 'FETCHING_USER';
- export const RECEIVED_USER = 'RECEIVED_USER';
- const fetchingUser = () => {
- return {
- type: FETCHING_USER
- }
- }
- const receivedUser = (data) => {
- return {
- type: RECEIVED_USER,
- data
- }
- }
- export const fetchingCollection = async (id) => {
- return async function(dispatch) {
- dispatch(fetchingUser());
- await fetch('https://api.themoviedb.org/3/movie/'+id+'?api_key='+API_KEY+'&language=en-US')
- .then( res => res.json() )
- .then( data => {dispatch(receivedUser(data)); console.log(data) });
- }
- }
- export const displayCollection = async (array) => {
- for(const item of array){
- await fetchingCollection(item);
- }
- console.log('done');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement