Files
test-product-compare-react/src/actions/product.js

18 lines
388 B
JavaScript

import * as types from '../constants/types'
export const getProducts = () =>
dispatch =>
fetch(`products.json`)
.then(response => response.json())
.then(response => {
dispatch({
type: types.FETCH_PRODUCTS,
payload: response.products
})
})
export const compare = product => ({
type: types.COMPARE_PRODUCT,
product
})