我有check-session
api,检查会话是否仍然有效。我想在每个请求中检查它,这意味着我想在Http Interceptor
Angular 4
中的每个请求之前调用此api。
return next.handle(req).do((event: HttpEvent<any>) => {
const http = this.inj.get(HttpClient);
http.get('/api/auth/check-session').subscribe(res => {
console.log('res', res);
});
在服务器网站上,它看起来像:
@RequestMapping(value = "/check-session", method = RequestMethod.GET)
@ResponseBody
public Boolean checkToken(HttpServletRequest request) {
boolean requestedSessionIdValid = request.isRequestedSessionIdValid();
return request.isRequestedSessionIdValid();
}
但是,当我启动我的应用程序并想要先调用api时,我收到错误:
ERROR RangeError: Maximum call stack size exceeded
at Observable.webpackJsonp.../../../../rxjs/Observable.js.Observable._trySubscribe (Observable.js:177)
at Observable.webpackJsonp.../../../../rxjs/Observable.js.Observable.subscribe (Observable.js:160)
有没有人知道如何摆脱这个错误?