且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 .pipe() 在 Angular 中检索响应头

更新时间:2023-02-15 09:51:16

您可以在管道内执行您的本地存储代码,如下所示.

You can do your local storage code inside the pipe as below.

     createVisitor() {
        // Create the visitor to send to API
        // TODO: Capture the params of the URL and not the full URL
        this.visitor = {
          BrandCode: 'honey',
          QueryString: 'example=qstring'
        };
    
        // Set Token as Session & Return a Success/Fail
        return this.http.post(this.api + this.controller + 'createvisitor', this.visitor, {observe: 'response'}).pipe(
          map((response: any) => {
            console.log(response.headers.keys());// all header names
 console.log(response.body); // response content

          })
        );
      }