简体   繁体   English

余烬适配器密码

[英]ember adapter pass id

I want to be able to pass an id to rest point while using ember data. 我希望能够在使用余烬数据时将ID传递到休息点。 My end-point looks like v3/enterprise/inventory/items/{id}/links. 我的端点看起来像v3 /企业/库存/物品/ {id} /链接。 I want to inject the id while making the request such as this.store.findAll('each-item-links', { id: itemId }). 我想在发出诸如this.store.findAll('each-item-links',{id:itemId})之类的请求时注入ID。 However, it does not work. 但是,它不起作用。 I extended the Ember REST adapter and override the namespace but nothing seems to be working. 我扩展了Ember REST适配器并覆盖了名称空间,但似乎没有任何效果。

If you're trying to request a single record through Ember Data, then you want to use findRecord instead of findAll . 如果您尝试通过Ember Data请求单个记录,那么您想使用findRecord而不是findAll

Also, if you need control over how the URL is built (what you have there looks like it might not map to the RESTAdapter too cleanly) you can override the _buildURL method to change the URL that the request is sent to. 另外,如果您需要控制URL的构建方式(您所拥有的内容看起来可能不太干净地映射到RESTAdapter ),则可以覆盖_buildURL方法以更改将请求发送到的URL。 It is given the ID from findRecord so you can generate the URL whatever you want. 它从findRecord获得ID,因此您可以根据需要生成URL。 Technically this is "private API" but I wouldn't worry too much about overwriting that. 从技术上讲,这是“私有API”,但是我不必担心重写。

Edit: To avoid using private API, there is also a public buildURL method that can be used instead. 编辑:为避免使用私有API,也可以使用公共的buildURL方法代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM