aretherecookies-mobile/js/apis/QuantityApi.js

28 lines
633 B
JavaScript
Raw Normal View History

// @flow
import type { Quantity } from '../constants/QuantityConstants';
import { BASE_URL } from '../constants/AppConstants';
import type { QuantityResponse } from '../constants/QuantityConstants';
export const setQuantity = ({
foodItemId,
quantity,
}: {
foodItemId: string,
quantity: Quantity,
}): ?Promise<QuantityResponse> => {
try {
return fetch(`http://${BASE_URL}/quantity`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
foodItemId,
quantity,
}),
}).then(res => res.json());
} catch (error) {
console.log(error); //eslint-disable-line
}
};