响应状态代码为空 Angular
Response status code getting null Angular
我在 angular 7 中实现了 post 方法。我想要 post 请求的状态码。
我关注了
const sub = this.service.regEvent(this.pId, this.email)
.subscribe(response => {
console.log('response:', response);
if(response.httpStatusCode === 200) {
}
});
this.subscriptions.push(sub);
regEvent 方法
public regEvent(pId, email): Observable<any> {
return this.http.post<any>(`this.endpointUrl?eventId=${pId}&email=${email}`,"").pipe(
catchError(this.handleError)
);
}
这里console.log('response:', response);
我正在获取null。
在浏览器中我检查了一下,它是。
在post人也。
如有任何帮助,我们将不胜感激。
你需要类似
的东西
this.http.post<any>(`this.endpointUrl?eventId=${pId}&email=${email}`,"",{observe: 'response'})
我在 angular 7 中实现了 post 方法。我想要 post 请求的状态码。
我关注了
const sub = this.service.regEvent(this.pId, this.email)
.subscribe(response => {
console.log('response:', response);
if(response.httpStatusCode === 200) {
}
});
this.subscriptions.push(sub);
regEvent 方法
public regEvent(pId, email): Observable<any> {
return this.http.post<any>(`this.endpointUrl?eventId=${pId}&email=${email}`,"").pipe(
catchError(this.handleError)
);
}
这里console.log('response:', response);
我正在获取null。
在浏览器中我检查了一下,它是。
在post人也。
如有任何帮助,我们将不胜感激。
你需要
this.http.post<any>(`this.endpointUrl?eventId=${pId}&email=${email}`,"",{observe: 'response'})