Created
November 4, 2017 19:29
-
-
Save j-mcnally/23f47198f6a80e963dab4ad748a73951 to your computer and use it in GitHub Desktop.
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 _fetch from 'fetch' | |
import Config from '../config/environment'; | |
import Ember from 'ember' | |
export default Ember.Service.extend({ | |
session: Ember.inject.service('session'), | |
fetch(url, options={}) { | |
return new Promise((resolve, reject) => { | |
this.get('session').authorize('authorizer:devise', (headerName, headerContent) => { | |
options = Object.assign({headers: {}}, options) | |
let authHeaders = {} | |
authHeaders[headerName] = headerContent | |
options["headers"] = Object.assign(options["headers"], authHeaders) | |
resolve(_fetch(`${Config.api.host}${url}`, options)); | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment