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 = {
log?: ILogItem;
allowedErrors?: number[];
allowedStatusCodes?: number[];
uploadProgress?: (loadedBytes: number) => void;
timeout?: number;
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 {
options.allowedErrors = [401];
options.allowedStatusCodes = [401];
const body: any = {
auth,
password,

View file

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