fix(core): update

This commit is contained in:
2020-06-25 23:53:05 +00:00
parent 5d673799cc
commit 5acbf420ae
7 changed files with 407 additions and 342 deletions

View File

@ -42,12 +42,11 @@ export class TypedHandler<T extends plugins.typedRequestInterfaces.ITypedRequest
data: typedResponseError.errorData
};
}
if (response) {
typedRequestArg.response = response;
}
return typedRequestArg;
}
}

View File

@ -2,6 +2,7 @@ import * as plugins from './typedrequest.plugins';
import { TypedResponseError } from './typedrequest.classes.typedresponseerror';
export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> {
public webrequest = new plugins.webrequest.WebRequest();
public urlEndPoint: string;
public method: string;
@ -15,16 +16,18 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
* firest the request
*/
public async fire(fireArg: T['request']): Promise<T['response']> {
const response = await plugins.smartrequest.postJson(this.urlEndPoint, {
requestBody: {
method: this.method,
request: fireArg,
response: null
}
const response = await this.webrequest.postJson(this.urlEndPoint, {
method: this.method,
request: fireArg,
response: null
});
const responseBody: T = response.body;
const responseBody: T = response;
if (responseBody.error) {
console.error(`Got an error ${responseBody.error.text} with data ${JSON.stringify(responseBody.error.data)}`);
console.error(
`Got an error ${responseBody.error.text} with data ${JSON.stringify(
responseBody.error.data
)}`
);
if (!responseBody.retry) {
throw new TypedResponseError(responseBody.error.text, responseBody.error.data);
}

View File

@ -7,4 +7,4 @@ export class TypedResponseError {
this.errorText = errorTextArg;
this.errorData = errorDataArg;
}
}
}

View File

@ -6,7 +6,6 @@ export { typedRequestInterfaces };
// pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartjson from '@pushrocks/smartjson';
import * as webrequest from '@pushrocks/webrequest';
export { lik, smartdelay, smartrequest, smartjson };
export { lik, smartdelay, webrequest };