Sha256: c80f13074d5a8343daedaaa454c7f26d4e8b4c3be75e4246052f0c5fcef77437
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
import * as types from '../constants/ActionTypes' import 'isomorphic-fetch' //const endpoint = 'http://localhost:3000' const endpoint = '' export function receiveProducts(products) { return { type: types.PRODUCT_RECEIVE, products: products } } export function searchProducts() { return dispatch => { return fetch(endpoint + '/api/products') .then(response => response.json()) .then(json => dispatch(receiveProducts(json))) } } export function showOrder(order) { console.log(order) return { type: types.PRODUCT_SHOW_ORDER, order: order } } export function salesOrder(product_id) { return dispatch => { return fetch(endpoint + '/api/sales_orders', { method: 'post', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ quantity: 10, shipment_date: '2014-03-21', product_id: product_id, customer_id: 1 }) }) .then(response => response.json()) .then(json => dispatch(showOrder(json))) } } export function hideSnackbar() { return { type: types.PRODUCT_HIDE_SNACKBAR } }
Version data entries
3 entries across 3 versions & 1 rubygems