Rename allowerErrors -> allowedStatusCodes

This commit is contained in:
RMidhunSuresh 2022-02-04 16:35:47 +05:30
parent 32af7e6f09
commit 891375a885
2 changed files with 4 additions and 4 deletions

View file

@ -38,7 +38,7 @@ type Options = {
type BaseRequestOptions = { type BaseRequestOptions = {
log?: ILogItem; log?: ILogItem;
allowedErrors?: number[]; allowedStatusCodes?: number[];
uploadProgress?: (loadedBytes: number) => void; uploadProgress?: (loadedBytes: number) => void;
timeout?: number; timeout?: number;
prefix?: string; prefix?: string;
@ -165,7 +165,7 @@ export class HomeServerApi {
} }
register(username: string | null, password: string, initialDeviceDisplayName: string, auth?: Record<string, any>, inhibitLogin: boolean = true , options: BaseRequestOptions = {}): IHomeServerRequest { register(username: string | null, password: string, initialDeviceDisplayName: string, auth?: Record<string, any>, inhibitLogin: boolean = true , options: BaseRequestOptions = {}): IHomeServerRequest {
options.allowedErrors = [401]; options.allowedStatusCodes = [401];
const body: any = { const body: any = {
auth, auth,
password, password,

View file

@ -27,7 +27,7 @@ export interface IHomeServerRequest {
type HomeServerRequestOptions = { type HomeServerRequestOptions = {
log?: ILogItem; log?: ILogItem;
allowedErrors?: number[]; allowedStatusCodes?: number[];
}; };
export class HomeServerRequest implements IHomeServerRequest { export class HomeServerRequest implements IHomeServerRequest {
@ -47,7 +47,7 @@ export class HomeServerRequest implements IHomeServerRequest {
this._promise = sourceRequest.response().then(response => { this._promise = sourceRequest.response().then(response => {
log?.set("status", response.status); log?.set("status", response.status);
// ok? // ok?
if (response.status >= 200 && response.status < 300 || options?.allowedErrors?.includes(response.status)) { if (response.status >= 200 && response.status < 300 || options?.allowedStatusCodes?.includes(response.status)) {
log?.finish(); log?.finish();
return response.body; return response.body;
} else { } else {