首页 新闻 会员 周边

angular: 如何通过 HttpClient 发 HEAD 请求并获取响应状态码

0
悬赏园豆:30 [已解决问题] 解决于 2022-10-16 18:11

最近在学习 angular,请问如何通过 HttpClient 发生 http head 请求并获取 response status code?

dudu的主页 dudu | 高人七级 | 园豆:30994
提问于:2022-10-16 10:21
< >
分享
最佳答案
0

通过下面的代码实现了

this.httpClient.head("/auth/is-signed-in", { observe: 'response' }).pipe(
  map(response => {
    console.log(response.status);
  }),
  catchError(error => {
    console.log(error.status);
    return of(undefined);
  })
).subscribe();
dudu | 高人七级 |园豆:30994 | 2022-10-16 18:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册