1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-18 21:12:48 +00:00

added check fetching functionality

This commit is contained in:
2016-08-27 07:30:32 +00:00
parent 4bcb240e97
commit d173b06129
6 changed files with 33 additions and 8 deletions

View File

@@ -15,10 +15,17 @@ function loadPost(post){
}
}
function fetching(){
return{
type: types.FETCHING
}
}
//using redux-thunk we can modify actions before they get called
//in this case we can send the http request here rather in the react component
export function fetchPreview() {
return (dispatch) => {
dispatch(fetching());
return fetch('/public/metadata.json')
.then(response => response.json())
.then(json => {
@@ -32,6 +39,7 @@ export function fetchPreview() {
export function fetchPost(category, post) {
return (dispatch) => {
dispatch(fetching());
return fetch(`/public/posts/${category}/${post}.md`)
.then(response => response.text())
.then(response => {