I am currently trying to figure out how to access metadata when using the store.findRecord()
call.
In the guides (http://guides.emberjs.com/v2.1.0/models/handling-metadata/) it says that metadata can be accessed by doing the following:
store.query('post').then((result) => {
let meta = result.get('meta');
})
I was hoping this would work when using findRecord
as well
store.findRecord('book', params.id, {adapterOptions: {query: params}}).then((result) => {
let meta = result.get('meta');
})
However this always returns undefined for the meta
property. I'm assuming that metadata is not being set when using findRecord
. I am returning valid JSON-API with a meta
property at the top level like this:
{
"meta": {
"page": {
"number": 1,
"size": 100,
"total": 20
},
"data":[
// data here
]
}
}
Is there a way to access the metadata returned by the server when using findRecord() and the JSONAPISerializer and JSONAPIAdapters?
Thank you!
I am using the following versions:
Ember : 2.1.0
Ember Data : 2.1.0
jQuery : 1.11.3
metadata are not supported per-record basis, you can count of having them available if you use store.query()
or when fetching relationships.
Quoting:
For now, Ember Data only understands a top level meta object on queries and relationships (through related links).
Take a look at the following github thread for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With