Skip to content

Instantly share code, notes, and snippets.

@GCheung55
Last active June 18, 2020 19:31
Show Gist options
  • Save GCheung55/8a6a03f70a4e1b90d7e5e23d6ffa8a7d to your computer and use it in GitHub Desktop.
Save GCheung55/8a6a03f70a4e1b90d7e5e23d6ffa8a7d to your computer and use it in GitHub Desktop.
Example async setting headers in adapter.
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
async ajax(...args) {
// Store the parent call, so it can be called after getting the current session.
const _super = this._super.bind(this);
// Sorry, I'm unfamiliar with how you're accessing amplify
const headers = await amplify.currentSession();
this.set('headers', {
'Authentication': headers.auth
});
return _super(...args);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment