stream-saga/src/js/actions/index.js

16 lines
395 B
JavaScript
Raw Normal View History

2019-06-19 14:24:21 -04:00
import { ADD_ARTICLE } from "../constants/action-types"
export function addArticle(payload) {
2019-06-19 16:37:03 -04:00
return { type: ADD_ARTICLE, payload }
2019-06-19 14:24:21 -04:00
}
2019-06-19 17:08:53 -04:00
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 });
})
}
}