diff --git a/src/apis/back.ts b/src/apis/back.ts index 578adbb24004cec9c955afe30a50587ef879788a..9604a7c56c91a7ad0e563ce506922e4de8da2720 100644 --- a/src/apis/back.ts +++ b/src/apis/back.ts @@ -30,4 +30,25 @@ export async function getItems(): Promise<Product[]> { })); return products; +} + +export async function setStock(name: number, stock: number): Promise<void> { + const response = await axios.put(`${BASE_URL}/stock`, { + item_id: name, + quantity: stock + }, { + headers: { + 'Content-Type': 'application/json', + 'apikey': APIKEY, + } + }) + .then(({ data }) => data) + .catch(error => { + console.error(error); + return "Error"; + }); + + return response; }; + +