vendredi 15 mars 2019

Ember-simple-auth and ember-fetch no authorization in fetch query

I am using ember with ember-simple-auth(1.7.0) for authentication. Here is the application adapter function :

authorize(xhr) {
    let { email, token } = this.get('session.data.authenticated');
    let authData = `Token token="${token}", email="${email}"`;
    xhr.setRequestHeader('Authorization', authData);
  }

When I use ember-fetch(5.1.3) there is no header for authentication :

fetch('/appname/v1/user/count'+count_params).then((response)=>{return response.json()})

The same model do successful emberDS query with the auth info in the header. How can I add the information to the fetch headers ?




Aucun commentaire:

Enregistrer un commentaire