ember 2.2.0 this.store.queryRecord returns Error: Adapter operation failed at new Error (native) at Error.EmberError

自闭症网瘾萝莉.ら 提交于 2019-12-12 03:13:49

问题


I am using ember 2.2.0 with ember-pouch, so my problem is that I am trying to retrieve data from the store by param different than id here is my code:

this.store.queryRecord('facility', { api_number: '42-001-1234'})

and it fails it following error:

GET http://localhost:4200/facilities?api_number=42-001-1234 404 (Not Found) send @ jquery.js:9664jQuery.extend.ajax @ jquery.js:9215(anonymous function) @ rest-adapter.js:764initializePromise @ ember.debug.js:52308Promise @ ember.debug.js:54158ember$data$lib$system$adapter$$default.extend.ajax @ rest-adapter.js:729ember$data$lib$system$adapter$$default.extend.queryRecord @ rest-adapter.js:404ember$data$lib$system$store$finders$$_queryRecord @ finders.js:168ember$data$lib$system$store$$Service.extend.queryRecord @ store.js:897chooseFacility @ facility.js:16_emberMetalMixin.Mixin.create.send @ ember.debug.js:31366runRegisteredAction @ ember.debug.js:28471Backburner.run @ ember.debug.js:681run @ ember.debug.js:20105actions.push.handler @ ember.debug.js:28465(anonymous function) @ ember.debug.js:43052jQuery.event.dispatch @ jquery.js:4670elemData.handle @ jquery.js:4338 ember.debug.js:30877 Error: Adapter operation failed at new Error (native) at Error.EmberError (http://localhost:4200/assets/vendor.js:26414:21) at Error.ember$data$lib$adapters$errors$$AdapterError (http://localhost:4200/assets/vendor.js:67497:50) at ember$data$lib$system$adapter$$default.extend.handleResponse (http://localhost:4200/assets/vendor.js:68801:16) at hash.error (http://localhost:4200/assets/vendor.js:68881:33) at fire (http://localhost:4200/assets/vendor.js:3350:30) at Object.self.fireWith [as rejectWith] (http://localhost:4200/assets/vendor.js:3462:7) at done (http://localhost:4200/assets/vendor.js:9518:14) at XMLHttpRequest.callback (http://localhost:4200/assets/vendor.js:9920:8)onerrorDefault @ ember.debug.js:30877exports.default.trigger @ ember.debug.js:52928(anonymous function) @ ember.debug.js:54177Queue.invoke @ ember.debug.js:320Queue.flush @ ember.debug.js:384DeferredActionQueues.flush @ ember.debug.js:185Backburner.end @ ember.debug.js:563Backburner.run @ ember.debug.js:685run @ ember.debug.js:20105hash.error @ rest-adapter.js:761fire @ jquery.js:3148self.fireWith @ jquery.js:3260done @ jquery.js:9316callback @ jquery.js:9718


回答1:


It looks like your problem is not on the Ember side, but in your backend. The query is correctly translated into a GET request with URL parameters, but your backend server returns a 404. If you use the returning promise, for example like this:

this.store.queryRecord('facility', { api_number: '42-001-1234'})
.then(function(result) {...})
.catch(function(error) {...});

you can handle the exception.



来源:https://stackoverflow.com/questions/34411661/ember-2-2-0-this-store-queryrecord-returns-error-adapter-operation-failed-at-ne

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!