我试图在拦截器中引发可观察到的错误,然后处理该错误。但是我不能。如果成功为假,我也可以收到成功的订阅。
我尝试在中再次返回一个值next.handle(restReq)
。但是我失败了,没有订阅任何东西
{
"success": false,
"data": {
"name": "Bad Request",
"message": "123",
"code": 0,
"status": 400,
"type": "yii\\web\\BadRequestHttpException"
}
}
Run Code Online (Sandbox Code Playgroud)
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/internal/Observable';
@Injectable({
providedIn: 'root'
})
export class AuthService {
private sessionUrl = '/wechat/session';
constructor(
private http: HttpClient
) { }
getSession(): Observable<any> {
return this.http.post<any>(this.sessionUrl, {});
}
}
Run Code Online (Sandbox Code Playgroud)
import { Component, OnInit } from '@angular/core';
import { AuthService …
Run Code Online (Sandbox Code Playgroud)