I'm having a frustrating time, and I'm not sure if it's Ember Mirage causing the problem or not. I have the following code in a service.
Ember.$.get({
url: `/api/online-courses/${Ember.get(course, 'id')}/courseData`,
async: false, // use of deferreds, or promises, is deprecated with this setting
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', Ember.get(service, 'ajax.headers')['Authorization'])
},
success: (result) => {
globalState.initialized = true
Ember.get(service, 'store').pushPayload('course-datum', result)
initializeValues()
returnVal = 'true'
},
error: (args) => {
returnVal = 'false'
}
})
return returnVal
I also have the route declared in my mirage/config.js
file. It is set up to only use mirage during unit tests.
During the tests, I can follow the code execution through the XHR request, into the Mirage route handler, and then... nothing. It doesn't hit either of the success or error handlers defined in the Ember.$.get
When I execute this code in development against a real web-server, it works fine.
Does Mirage support the async:false
flag? I also tried using this.pretender.get
syntax to declare my end-point using the synchronous style defined here: http://ift.tt/25cIHNH But still no joy...
Any ideas, nudges in the right direction, etc. would be hugely appreciated.
Aucun commentaire:
Enregistrer un commentaire