mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-23 04:10:40 +03:00
19 lines
438 B
JavaScript
19 lines
438 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.result.error) return alert(res.result.error);
|
||
|
|
||
|
return res;
|
||
|
|
||
|
} catch (err) {
|
||
|
alert(err);
|
||
|
}
|
||
|
|
||
|
}
|