forked from mystiq/hydrogen-web
Rename allowerErrors -> allowedStatusCodes
This commit is contained in:
parent
32af7e6f09
commit
891375a885
2 changed files with 4 additions and 4 deletions
|
@ -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,
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue