We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
chapters
this.api.get('/books/3').chapters()
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:
chaptersLink
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().
chaptersLink()
The text was updated successfully, but these errors were encountered:
Reading the hal-json-normalizer docu, this discussion and this discussion, then the current behavior should not return undefined. Maybe rather a bug than an enhancement?
undefined
Sorry, something went wrong.
Hm I'll have to take a look at this. Thanks for the report!
No branches or pull requests
Assuming the following API payload which contains a link that is named the same as an embedded collection:
Current behavior
I cannot read the
chapters
links, asthis.api.get('/books/3').chapters()
is overwritten by the embedded collection.Proposed behavior
Expose all links in _meta object.
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:However, with this I'll trigger an unnecessary API request to
chaptersLink()
.The text was updated successfully, but these errors were encountered: