I am new to Ember/Ember-Data, and have stumbled across an issue which I cannot figure out. I was successfully able to invoke PUT and POST requests using Ember-Data's RESTAdapter, but for some reason it stopped working.
The issue is that the calls are getting invoked correctly, but without any json data being sent in the Request Body.
I stepped through the Ember/Ember-Data/JQuery Code until I found the spot where the data was being deleted.
For clarity, I am using the following versions of the frameworks:
Where the data is getting removed is in Ember-Data, in the implementation of the RESTAdapter. Specifically the implementation of the ajax
method.
Here is the method:
ajax: function (url, type, hash) {
var adapter = this;
return new Ember.RSVP.Promise(function (resolve, reject) {
var hash = adapter.ajaxOptions(url, type, hash);
hash.success = function (json) {
Ember.run(null, resolve, json);
};
hash.error = function (jqXHR, textStatus, errorThrown) {
Ember.run(null, reject, adapter.ajaxError(jqXHR));
};
Ember.$.ajax(hash);
});
},
The hash
value is where the POST/PUT's BODY data is stored, and when it hits this line
var adapter = this;
The hash
parameter contains the JSON data.
However, when Ember.RSVP.Promise
's function gets fired, the hash
is undefined
. The url
and type
are still populated with their original data.
I have never worked with Promises, and am unsure how/why this would be deleting the data.
Since this was working before, I could have done something that broke how it worked.
If anyone knows why this is happening and what I can do to fix it, it would be greatly appreciated.
UPDATE this should be fixed now.
We are just waiting for the fix to be merged .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.