mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 07:54:57 -06:00
28 lines
633 B
JavaScript
28 lines
633 B
JavaScript
|
|
// @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
|
||
|
|
}
|
||
|
|
};
|