Redux-saga

This commit is contained in:
Rodrigo Pedroso 2019-06-19 22:37:59 -04:00
commit df88e7261e
3 changed files with 27 additions and 9 deletions

View file

@ -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" }
}