akf-forum/public/js/request.js
Akif9748 4be2069587 3lü ve güçlü
Co-authored-by: Sapphire1525 <Sapphire1525@users.noreply.github.com>

Co-authored-by: inoaa79 <inoaa79@users.noreply.github.com>
2022-08-24 22:09:21 +03:00

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);
}
}