forked from mirrors/homebox
frontend: cleanup
* dummy commit * cleanup workflows * setup and run eslint * add linter to CI * use eslint for formatting * reorder rules * drop editor config
This commit is contained in:
parent
78fa714297
commit
75c633dcb5
65 changed files with 2048 additions and 641 deletions
|
@ -1,8 +1,8 @@
|
|||
export enum Method {
|
||||
GET = 'GET',
|
||||
POST = 'POST',
|
||||
PUT = 'PUT',
|
||||
DELETE = 'DELETE',
|
||||
GET = "GET",
|
||||
POST = "POST",
|
||||
PUT = "PUT",
|
||||
DELETE = "DELETE",
|
||||
}
|
||||
|
||||
export type RequestInterceptor = (r: Response) => void;
|
||||
|
@ -40,9 +40,9 @@ export class Requests {
|
|||
return this.baseUrl + rest;
|
||||
}
|
||||
|
||||
constructor(baseUrl: string, token: string | (() => string) = '', headers: Record<string, string> = {}) {
|
||||
constructor(baseUrl: string, token: string | (() => string) = "", headers: Record<string, string> = {}) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.token = typeof token === 'string' ? () => token : token;
|
||||
this.token = typeof token === "string" ? () => token : token;
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
|
@ -72,19 +72,19 @@ export class Requests {
|
|||
headers: {
|
||||
...rargs.headers,
|
||||
...this.headers,
|
||||
},
|
||||
} as Record<string, string>,
|
||||
};
|
||||
|
||||
const token = this.token();
|
||||
if (token !== '' && payload.headers !== undefined) {
|
||||
payload.headers['Authorization'] = token;
|
||||
if (token !== "" && payload.headers !== undefined) {
|
||||
payload.headers["Authorization"] = token; // eslint-disable-line dot-notation
|
||||
}
|
||||
|
||||
if (this.methodSupportsBody(method)) {
|
||||
if (rargs.data) {
|
||||
payload.body = rargs.data;
|
||||
} else {
|
||||
payload.headers['Content-Type'] = 'application/json';
|
||||
payload.headers["Content-Type"] = "application/json";
|
||||
payload.body = JSON.stringify(rargs.body);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue