Open
Description
Assuming the following API payload which contains a link that is named the same as an embedded collection:
{
"name": "Book No #3",
"_links": {
"self": {
"href": "/books/3"
},
"chapters": {
"href": "/chapters?book=3"
}
},
"_embedded": {
"chapters": [
{
"_links": {
"self": "/chapters/1028"
}
},
{
"_links": {
"self": "/chapters/1029"
}
},
]
}
}
Current behavior
I cannot read the chapters
links, as this.api.get('/books/3').chapters()
is overwritten by the embedded collection.
let book = this.api.get('/books/3')
console.log(book.chapters()._meta.self) // --> undefined
Proposed behavior
Expose all links in _meta object.
let book = this.api.get('/books/3')
console.log(book._meta.links.chapters) // --> '/chapters?book=3'
this.api().post(book._meta.links.chapters, { title: 'Awesome new chapter' } )
This could help to avoid the need for templated links when posting to new objects.
Possible workaround
A workaround possible today is to use a different name for the link, e.g. chaptersLink
and then do:
let book = this.api.get('/books/3')
console.log(book.chaptersLink()._meta.self) // --> '/chapters?book=3'
this.api().post(book.chaptersLink()._meta.self, { title: 'Awesome new chapter' }
However, with this I'll trigger an unnecessary API request to chaptersLink()
.