ember 2.2.0 this.store.queryRecord返回错误:Error.EmberError处的新错误(本机)上的适配器操作失败

时间:2022-08-13 22:51:09

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:

我正在使用带有ember-pouch的ember 2.2.0,所以我的问题是我试图通过不同于id的param从商店检索数据这里是我的代码:

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

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

获取http:// localhost:4200 / facilities?api_number = 42-001-1234 404(未找到)发送@jquery.js:9664jQuery.extend.ajax @jquery.js:9215(匿名函数)@ 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(匿名函数)@ ember.debug.js:43052jQuery.event.dispatch @jquery.js:4670elemData.handle @jquery.js:4338 ember.debug.js:30877错误:在Error.EmberError(http:// localhost:4200 / ass)的新错误(本机)上,适配器操作失败ets / vendor.js:26414:21)在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)在XMLHttpRequest.callback(http:// localhost:4200 / assets / vendor.js:9920:8)onerrorDefault @ ember .debug.js:30877exports.default.trigger @ ember.debug.js:52928(匿名函数)@ 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:3260d one @jquery.js:9316callback @jquery.js:9718

1 个解决方案

#1


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:

看起来你的问题不在Ember方面,而在你的后端。查询已正确转换为带有URL参数的GET请求,但您的后端服务器返回404.如果您使用返回的promise,例如:

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

you can handle the exception.

你可以处理异常。

#1


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:

看起来你的问题不在Ember方面,而在你的后端。查询已正确转换为带有URL参数的GET请求,但您的后端服务器返回404.如果您使用返回的promise,例如:

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

you can handle the exception.

你可以处理异常。