Changed client to add token to logout call

This commit is contained in:
2025-03-17 22:29:05 +01:00
parent ec9d9ad1c5
commit 967211565b

View File

@@ -1,3 +1,5 @@
import { useUserStore } from "~/hooks/user";
interface get { interface get {
"/item": { "/item": {
parameters: { parameters: {
@@ -37,6 +39,7 @@ interface post {
username: string; username: string;
password: string; password: string;
}; };
token?: never;
}; };
return: User; return: User;
}; };
@@ -44,6 +47,7 @@ interface post {
parameters: { parameters: {
query?: never; query?: never;
body?: never; body?: never;
token: string;
}; };
return?: never; return?: never;
}; };
@@ -55,6 +59,7 @@ interface post {
password: string; password: string;
email: string; email: string;
}; };
token?: never;
}; };
return?: never; return?: never;
}; };
@@ -78,6 +83,7 @@ export interface Case {
export interface User { export interface User {
uuid: string; uuid: string;
username: string; username: string;
token: string;
} }
class Client { class Client {
@@ -96,6 +102,7 @@ class Client {
: ""; : "";
let response = await fetch(this.baseUrl + path + query, { let response = await fetch(this.baseUrl + path + query, {
method: "GET", method: "GET",
credentials: "include",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
@@ -114,8 +121,12 @@ class Client {
let response = await fetch(this.baseUrl + path + query, { let response = await fetch(this.baseUrl + path + query, {
method: "POST", method: "POST",
body: JSON.stringify(parameters["body"]), body: JSON.stringify(parameters["body"]),
credentials: "include",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Authorization: parameters["token"]
? "Bearer " + parameters["token"]
: "",
}, },
}); });
let data; let data;