Can set member photo

This commit is contained in:
2023-08-10 12:10:09 +02:00
parent 10e8f339cc
commit d1e55d574e
12 changed files with 450 additions and 35 deletions

View File

@ -29,16 +29,31 @@ export class APIClient {
method: "GET" | "POST" | "DELETE" | "PATCH" | "PUT";
allowFail?: boolean;
jsonData?: any;
formData?: FormData;
}): Promise<APIResponse> {
let body = undefined;
let headers: any = {
"X-auth-token": AuthApi.SignedIn ? AuthApi.AuthToken : "none",
};
// JSON request
if (args.jsonData) {
headers["Content-Type"] = "application/json";
body = JSON.stringify(args.jsonData);
}
// Form data request
else if (args.formData) {
body = args.formData;
}
const res = await fetch(this.backendURL() + args.uri, {
method: args.method,
body: args.jsonData ? JSON.stringify(args.jsonData) : undefined,
headers: {
"X-auth-token": AuthApi.SignedIn ? AuthApi.AuthToken : "none",
"Content-Type": args.jsonData ? "application/json" : "text/plain",
},
body: body,
headers: headers,
});
// Process response
let data;
if (res.headers.get("content-type") === "application/json")
data = await res.json();