Last active
June 18, 2020 19:31
-
-
Save GCheung55/8a6a03f70a4e1b90d7e5e23d6ffa8a7d to your computer and use it in GitHub Desktop.
Example async setting headers in adapter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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