我有一个API,需要在此URI处发出GET请求:
/rooms/500
将返回所有可容纳500人的会议室。该数字可能因用户输入而有所不同。
我正在使用Ember.js,我的适配器看起来像这样,硬编码用于测试:
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
namespace: 'rooms/500',
});
但是模型名称(rooms
)总是连接到请求,使其成为/rooms/500/rooms
,没有端点。如何让Ember停止更改namespace
?
谢谢。
答案 0 :(得分:1)
namespace
has another purpose. It used as a prefix for all your request with this adapter. You can read in details here.
By convention, number after resource name used as resource id. In your case:
rooms
- resource name500
- resource idSo to get what you need you can use next code in your controller/route:
store.findRecord('room', 500);