diff --git a/src/pages/debug/utils.js b/src/pages/debug/utils.js index 0701434..fa74b1c 100644 --- a/src/pages/debug/utils.js +++ b/src/pages/debug/utils.js @@ -1,7 +1,7 @@ -// FIXME: File that provide utils function for the debug page import $ from "jquery"; import jwt_decode from "jwt-decode"; import { createAlert } from "../../utils/notify"; +import {authedAPIRequest} from "../../utils/auth" export async function displayStudentProfile() { const token = localStorage.getItem("token"); @@ -10,7 +10,7 @@ export async function displayStudentProfile() { const _uid = decoded.uid; // You have to write a request to fetch your informations - const request_result = null; + // const request_result = authedAPIRequest(`/api/students/${_uid}`, {method: "GET"}); if (request_result === null) { createAlert( diff --git a/src/utils/auth.js b/src/utils/auth.js index c492072..a012f5e 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -9,9 +9,9 @@ async function sendRequest(endpoint, body) { const request = { method: "POST", - headers: { - "Content-Type": "application/x-www-form-urlencoded", - }, + // headers: { + // "Content-Type": "application/x-www-form-urlencoded", + // }, body: formData, }; @@ -130,7 +130,6 @@ async function authenticate() { * body, rather than just the body */ async function authedAPIRequest(endpoint, options) { - console.log("Attemtping to make a request to: " + endpoint); // TODO remove if (!authenticate()) { return null; } @@ -146,10 +145,11 @@ async function authedAPIRequest(endpoint, options) { options.headers.Authorization = localStorage.getItem("token"); options.mode = "cors"; + const full_endpoint = import.meta.env.VITE_URL + endpoint; let response; try { - response = await fetch(endpoint, options); + response = await fetch(full_endpoint, options); if (!response.ok) { throw new Error(response.statusText); }