This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import config from "./config"; | |
export const requestProducts = () => ({ | |
type: "REQUEST_PRODUCTS" | |
}); | |
export const receiveProducts = products => ({ | |
type: "RECEIVE_PRODUCTS", | |
products | |
}); | |
export const fetchProducts = () => dispatch => { | |
dispatch(requestProducts()); | |
return fetch(config.API_PRODUCTS_URL) | |
.then(response => response.json()) | |
.then(json => dispatch(receiveProducts(json))) | |
.catch(() => { | |
dispatch(receiveProducts([])); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment