How to add Authorization Header to Angular http request?

后端 未结 5 595
悲&欢浪女
悲&欢浪女 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:28

    Angular 6 ==> HTTP Get request example with Authorization Header

    public IsClientCreditCardExits(companyId: string, token: any) {
        let header = new Headers({ 'Authorization': `Bearer ${token}` });
        const options = new RequestOptions({
           headers: header,
        });
        return this._http.get(this.ApiURL + "api/Subscriptions/IsClientCreditCardExits/" + companyId + "/", options);    
    }
    

提交回复
热议问题