in frontend/utils.js [24:49]
export async function authPost(url, data, isPatch = false) {
const token = await getAuthToken();
const headers = {
"Content-Type": "application/json",
"X-CSRFToken": getCookie("csrftoken"),
Authorization: `Token ${token}`,
};
if (isPatch) {
headers["X-HTTP-Method-Override"] = "PATCH";
}
const res = await fetch(url, {
method: "POST",
headers,
body: data,
});
if (!res.ok) {
const msg = await res.text();
throw new Error(`Request failed: ${res.status} ${msg}`);
}
return res;
}