mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-29 14:10:41 +03:00
Akif9748
4be2069587
Co-authored-by: Sapphire1525 <Sapphire1525@users.noreply.github.com> Co-authored-by: inoaa79 <inoaa79@users.noreply.github.com>
19 lines
No EOL
424 B
JavaScript
19 lines
No EOL
424 B
JavaScript
export default async function request(link, method = "POST", body={}) {
|
|
try {
|
|
const res = await fetch(link, {
|
|
method,
|
|
body: JSON.stringify(body),
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
}
|
|
}).then(res => res.json())
|
|
|
|
if (res.error) return alert(res.error);
|
|
|
|
return res;
|
|
|
|
} catch (err) {
|
|
alert(err);
|
|
}
|
|
|
|
} |