Skip to content

Commit 0f6f611

Browse files
adding headers to post requests
1 parent 5de7793 commit 0f6f611

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/components/modals/reportModal.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import Toast from "../toast/toast.astro";
6767
fetch(backend_url + "api/report/new-report", {
6868
method: "POST",
6969
body: JSON.stringify(report),
70+
headers: { "Content-Type": "application/json" },
7071
})
7172
.then((response) => {
7273
const alert = `Reporte enviado satisfactoriamente. Gracias por contactarnos.`;

src/pages/editar-empleo.astro

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ for (const key in categories) {
149149
return;
150150
}
151151
try {
152-
const response = await fetch(`${backend_url}api/jobs/get-job?id=${jobId}`);
152+
const response = await fetch(`${backend_url}api/jobs/get-job?id=${jobId}`, {
153+
headers: { "Content-Type": "application/json" },
154+
});
153155
if (!response.ok) throw new Error("Failed to load job");
154156
const data = await response.json();
155157
populateForm(data);
@@ -226,7 +228,10 @@ for (const key in categories) {
226228
if (!confirm("¿Estás seguro de que quieres eliminar este empleo? Esta acción no se puede deshacer.")) return;
227229

228230
try {
229-
const response = await fetch(`${backend_url}api/jobs/delete-job?id=${jobId}`, { method: "DELETE" });
231+
const response = await fetch(`${backend_url}api/jobs/delete-job?id=${jobId}`, {
232+
method: "DELETE",
233+
headers: { "Content-Type": "application/json" },
234+
});
230235
if (!response.ok) throw new Error("Delete failed");
231236
window.open(`${window.location.origin}/empleo-eliminado`, "_self");
232237
} catch (e) {

src/pages/registro.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ import Toast from "../components/toast/toast.astro";
176176
fetch(backend_url + "api/members/create-invitation", {
177177
method: "POST",
178178
body: JSON.stringify({ email: email }),
179+
headers: { "Content-Type": "application/json" },
179180
})
180181
.then((response) => response.json())
181182
.then((data) => {

0 commit comments

Comments
 (0)