Skip to content
This repository was archived by the owner on Jul 7, 2021. It is now read-only.

Commit 7e07f09

Browse files
committed
implement the fetchPosts function in the postActions file
1 parent bef93fe commit 7e07f09

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/actions/postActions.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { FETCH_POSTS, NEW_POST } from "./types";
2+
3+
export function fetchPosts() {
4+
return function (dispatch) {
5+
fetch("https://jsonplaceholder.typicode.com/posts")
6+
.then((res) => res.json())
7+
.then((posts) =>
8+
dispatch({
9+
type: FETCH_POSTS,
10+
payload: posts,
11+
})
12+
);
13+
};
14+
}

0 commit comments

Comments
 (0)