I have the following situation:
export default class ApplicationAdapter extends JSONAPIAdapter {
@service auth;
@tracked bearer;
namespace = 'api/v1';
host = ENV.host;
headers = {
'Authorization': this.authorize()
}
async authorize() {
const accessToken = await this.auth.checkLogin();
return `Bearer ${accessToken}`;
}
}
as I want to to get the accessToken from the async checkLogin function in my not-async headers it does not work. I get a authorization: [object Promise] back and not the accesstoken.
How do I solve this as I cannot make the headers field async?
4 posts - 2 participants