yet-another-blog/frontend/public/js/generic.js

15 lines
455 B
JavaScript

// Quick document selectors
const qs = (selector) => document.querySelector(selector);
const qsa = (selector) => document.querySelectorAll(selector);
async function request(url, method, body) {
const response = await fetch(url, {
method: method,
headers: {
"Content-Type": "application/json", // Set the Content-Type header
},
body: JSON.stringify(body),
});
return { status: response.status, body: await response.json() };
}