9 lines
297 B
JavaScript
9 lines
297 B
JavaScript
export async function sendRequest(url, method, body) {
|
|
const res = await fetch(url, {
|
|
method,
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(body)
|
|
});
|
|
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
|
|
return res.json();
|
|
} |