fix: use URL.URL

This commit is contained in:
Derrick Hammer 2024-03-13 18:12:18 -04:00
parent 620e983011
commit d18e3a9da5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 5 deletions

View File

@ -24,13 +24,14 @@ import {
postApiAuthPasswordResetConfirm,
} from "./account/generated/index.js";
import { AxiosResponse } from "axios";
import * as URL from 'url';
export default class AccountApi {
private apiUrl: string;
private jwtToken?: string;
constructor(apiUrl: string) {
let apiUrlParsed = new URL(apiUrl);
let apiUrlParsed = new URL.URL(apiUrl);
apiUrlParsed.hostname = `account.${apiUrlParsed.hostname}`;
this.apiUrl = apiUrlParsed.toString();
@ -50,7 +51,7 @@ export default class AccountApi {
ret = this.checkSuccessVal<LoginResponse>(ret);
if (ret) {
this.jwtToken = (ret as LoginResponse).token;
this._jwtToken = (ret as LoginResponse).token;
return true;
}
@ -58,7 +59,7 @@ export default class AccountApi {
}
public async logout(): Promise<boolean> {
this.jwtToken = undefined;
this._jwtToken = undefined;
return true;
}
@ -192,8 +193,8 @@ export default class AccountApi {
private buildOptions(): any {
const headers: any = {};
if (this.jwtToken) {
headers.Authorization = `Bearer ${this.jwtToken}`;
if (this._jwtToken) {
headers.Authorization = `Bearer ${this._jwtToken}`;
}
return {