eplace/src/students/index.js
2026-05-16 17:18:47 +02:00

39 lines
1.1 KiB
JavaScript

import { authedAPIRequest } from "../utils/auth";
//get a student from the API by its uid or login
async function getStudent(login) {
if (!login) {
console.error("Cannot fetch an undefined student");
return;
}
const response = await authedAPIRequest("/students/" + login, {
method: "GET",
});
if (!response || !response.ok) {
console.error(
"Could not retrieve student: " + response
? response.statusText
: " no status text",
);
console.debug(await response.text());
return;
}
const res = await response.json();
console.debug(`Retrieved student ${login}:`);
console.debug(res);
// Update HTML
// const roomNameElt = document.getElementById("room-name");
// roomNameElt.innerText = res.metadata.name
}
//// get the user's uid from the token in local storage
async function getUserUidFromToken() {}
// update the student's profile through the API
async function updateStudent() {}
export { getStudent, getUserUidFromToken, updateStudent };