i extend my RestAdapter in adapter/application.js file and write a function "findOneQuery" to fetch the record from rails api with customized request call. but the issue is that when i use this function in oute.js file to fetch the record, it doesnt call and console.log shows undefined. on the other hand application adapter loads correctly because all my requests are working properly according to settings of my application adapter.
app/adapters/application.js
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
namespace: 'api',
coalesceFindRequests: true,
host: 'http://localhost:3000',
headers: {
Accept: 'application/json'
},
findOneQuery: function(type, id, query) {
console.log('*****************************Enter**');
var store = this;
var typeClass = store.modelFor(type);
var adapter = store.adapterFor(typeClass);
var serializer = store.serializerFor(typeClass);
var url = adapter.buildURL(type, id);
var ajaxPromise = adapter.ajax(url, 'GET', { data: query });
console.log('*************url*********',url);
console.log('*************type*********',type );
return ajaxPromise.then(function(rawPayload) {
var extractedPayload = serializer.extract(store, typeClass, rawPayload, id, 'find');
return store.push(typeClass, extractedPayload);
});
}
});
im using console.log just to check function called or not.
note.js file
`import Ember from 'ember'`
noteIndexRoute = Ember.Route.extend
model: (params)->
@store.findOneQuery('note',1,{id:99,type:'college'});
`export default noteIndexRoute`
findOneQuery is ignored by data store.
Ember : 1.10.0
Ember Data : 1.0.0-beta.16
Aucun commentaire:
Enregistrer un commentaire