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:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user