I'm about to request a get call to retrieve data from my server. I have enabled authorization to have a Bearer token in most of the requests. How can I include that when I request for something from the server? (what am I doing wrong here? Please help me out.)
For an example, I'm having a file named Categories.service.ts which is going to get categories from the server.
@Injectable({
providedIn: 'root'
})
export class CategoriesService {
private _url: string = "http://ifsstudents.educationhost.cloud/v2/categories/list";
constructor(private http:HttpClient) { }
private token: string="Bearer eyJ0eXA....";
getCategories():Observable<ICategory[]>{
let header = new HttpHeaders().set(
"Authorization",this.token
);
return this.http.get<ICategory[]>(this._url,{headers:header});
}
}
I have tested using Postman with the Bearer token, It's working without any issues.

