How to add Authorization Header to Angular http request?

后端 未结 5 590
悲&欢浪女
悲&欢浪女 2020-12-08 05:03

This is my first post.

I\'ve just started learning Go and Angular and I\'m attempting to connect the angular app to a go api. I\'ve written both and am stuck identi

5条回答
  •  天命终不由人
    2020-12-08 05:42

    Here is an example:

    this.http
            .get(url, return new RequestOptions({
              headers: new Headers({
                Authorization: `Bearer ${authtoken}`
              }),
            }))
            .map(res => res.json());
    

提交回复
热议问题