August 2017
Beginner
374 pages
10h 41m
English
Now that we have a thunkCreator utility function, let's use it instead of manually handling the promise:
import { thunkCreator } from './utils'
export const fetchPosts = () => thunkCreator({ types: [ FETCH_POSTS_REQUEST, FETCH_POSTS_SUCCESS, FETCH_POSTS_FAILURE ], promise: fetch('http://localhost:8080/api/posts') .then(response => response.json())})
import { createUser, fetchPosts } from './actions'
Read now
Unlock full access