in redux, dispatch asynchronous action, is usually written as 1. But do not understand the difference between 1 and 2, ask for guidance!
const fetchPosts = (postTitle) => (dispatch, getState) => {
dispatch({ type: "FETCH_POSTS_REQUEST" });
return fetch(`/some/API/${postTitle}.json`)
.then(response => response.json())
.then(json => dispatch(receivePosts(json)));
};
};
//1
store.dispatch(fetchPosts("reactjs")).then(() =>
//do sth.
);
//2
fetchPosts("reactjs").then(() =>
//do sth.
);