【发布时间】:2020-04-16 21:27:30
【问题描述】:
NestJS API App 使用 HttpService 调用另一个 API 并且它在没有使用自定义拦截器时工作。 HttpService API 调用已执行,但未到达其他 API 且无法看到响应。
这是获取调用代码
get(path: string, body: any = {}): Observable<AxiosResponse<any>> {
console.log('DomainAPI Response Begining');
const url = this.baseURL + path;
this.updateLastUtilizedTimestamp();
return this.httpService.get(url, { validateStatus: null }).pipe(
tap(data => {
console.log('DomainAPI Response Tap', data);
}),
retryWhen(
this.rxJSUtilsService.genericRetryStrategy({
numberOfAttempts: 3,
delayTime: 200,
ignoredErrorCodes: [500],
}),
),
catchError(this.formatErrors),
);
}
如果使用任何自定义拦截器,我在调试时发现以下内容。
arguments:TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
邮递员显示以下响应。
{
"statusCode": 500,
"message": {
"Title": "TypeError",
"Type": "Error",
"Detail": "Converting circular structure to JSON\n --> starting at object with constructor 'Observable'\n | property 'operator' -> object with constructor 'CatchOperator'\n --- property 'caught' closes the circle",
"Status": "Status",
"Extension": ""
},
"timestamp": "Exception - AllExceptionsFilter 2019-12-26T17:29:42.447Z"
}
我将上面的内容更改如下,但仍然无法正常工作
get(path: string, body: any = {}) {
console.log('DomainAPI Response Begining');
const url = this.baseURL + path;
this.updateLastUtilizedTimestamp();
return this.httpService.get(url, { validateStatus: null }).pipe(
map(response => {
console.log('DomainAPI Response Tap', response.data);
return response.data;
}),
);
}
它在邮递员中给出以下响应
{
"data": {
"_isScalar": false,
"source": {
"_isScalar": false,
"source": {
"_isScalar": false
},
"operator": {}
},
"operator": {}
}
}
请指教
【问题讨论】:
-
已找到任何解决方案。我遇到了同样的问题。
标签: node.js typescript axios nestjs