beuaah
This commit is contained in:
parent
0fb4513b4b
commit
0114214995
2 changed files with 5 additions and 3 deletions
|
|
@ -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 = authedAPIRequest(`/api/students/${_uid}`, {method: "GET"});
|
||||
const request_result = await authedAPIRequest(`/students/${_uid}`, {method: "GET"});
|
||||
|
||||
if (request_result === null) {
|
||||
createAlert(
|
||||
|
|
|
|||
|
|
@ -136,16 +136,17 @@ async function authedAPIRequest(endpoint, options) {
|
|||
|
||||
if (!options.method) {
|
||||
console.error("Invalid parameter: options (missing method)");
|
||||
return null
|
||||
}
|
||||
|
||||
if (!options.headers) {
|
||||
options.headers = {};
|
||||
}
|
||||
|
||||
options.headers.Authorization = localStorage.getItem("token");
|
||||
options.headers.Authorization = "Bearer " + localStorage.getItem("token");
|
||||
options.mode = "cors";
|
||||
|
||||
const full_endpoint = import.meta.env.VITE_URL + endpoint;
|
||||
const full_endpoint = import.meta.env.VITE_URL + "/api" + endpoint;
|
||||
let response;
|
||||
|
||||
try {
|
||||
|
|
@ -163,6 +164,7 @@ async function authedAPIRequest(endpoint, options) {
|
|||
}
|
||||
|
||||
localStorage.clear();
|
||||
alert("Redirecting to logging page")
|
||||
redirect.redirectToLoginPage();
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue