I am trying to load sample data from a REST API source that returns XML inside my emberjs application, but I am having two problems:
The model name is always in the plural, so instead of / sqlrest / CUSTOMER / 3 /, the code always generates / sqlrest / CUSTOMERS / 3 /
I know that DS.RESTAdaptor expects JSON format by default, so I was wondering if there is a way to get the XML format and can be converted to JSON?
thank
The code I use is as follows (this code, which I found in one of the SO answers and modified to match the URL I'm trying to get):
App.store = DS.Store.create({
revision: 11,
adapter: DS.RESTAdapter.create({
namespace: "sqlrest",
url: "http://www.thomas-bayer.com",
plurals: {
'customer': 'customer'
},
ajax: function (url, type, hash) {
hash.url = url;
hash.type = type;
hash.dataType = 'jsonp';
hash.contentType = 'application/json; charset=utf-8';
hash.context = this;
if (hash.data && type !== 'GET') {
hash.data = JSON.stringify(hash.data);
}
jQuery.ajax(hash);
},
})
});
and on the way:
App.CustomersRoute = Ember.Route.extend({
model: function() {
return App.Customer.find(18);
}
});
Mchan source
share