Redux-saga
This commit is contained in:
parent
5ecf405fde
commit
df88e7261e
3 changed files with 27 additions and 9 deletions
|
@ -5,11 +5,5 @@ export function addArticle(payload) {
|
|||
}
|
||||
|
||||
export function getData() {
|
||||
return function(dispatch) {
|
||||
return fetch("https://jsonplaceholder.typicode.com/posts")
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
dispatch({ type: "DATA_LOADED", payload: json });
|
||||
})
|
||||
}
|
||||
return { type: "DATA_REQUESTED" }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue