make it better
This commit is contained in:
1
src/actions/index.js
Normal file
1
src/actions/index.js
Normal file
@@ -0,0 +1 @@
|
||||
export * from './product';
|
||||
18
src/actions/product.js
Normal file
18
src/actions/product.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as types from '../constants/types';
|
||||
|
||||
export function getProducts() {
|
||||
return dispatch => {
|
||||
fetch(`${process.env.REACT_APP_API_URL}/v1/api/products`)
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
dispatch({
|
||||
type: types.FETCH_PRODUCTS,
|
||||
payload: response
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function compare(product) {
|
||||
return {type: types.COMPARE_PRODUCT, product};
|
||||
}
|
||||
Reference in New Issue
Block a user