renewToken API interface

This commit is contained in:
Imbus 2024-03-13 20:56:47 +01:00
parent e1bf25148e
commit 6afe6345cf

View file

@ -9,6 +9,8 @@ interface API {
removeUser(username: string): Promise<User>;
/** Create a project */
createProject(project: NewProject): Promise<Project>;
/** Renew the token */
renewToken(token: string): Promise<string>;
}
// Export an instance of the API
@ -42,4 +44,14 @@ export const api: API = {
body: JSON.stringify(project),
}).then((res) => res.json() as Promise<Project>);
},
async renewToken(token: string): Promise<string> {
return fetch("/api/loginrenew", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
},
}).then((res) => res.json() as Promise<string>);
},
};