You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With POST requests, the semantic implication is often that we POST to a collection, and the response contains a newly created entity that has a new self URI. In this case, the collection in the store will not contain the new entity after the response has arrived.
We could consider adding a configurable option or flag to the post / $post functions that allows to automatically reload the collection after the POST request has completed. This seems like a usual pattern that hal-json-vuex users would have to do manually otherwise, and it would be similar to the behaviour of delete, where we reload any collection and entity that "know" the deleted entity.
We should probably only reload the collection if it was loaded in the store already.
Thoughts on this? I'd imagine to use it like this:
// will automatically reload /books after the POST was successfulthis.api.get().books().$post({name: 'Moby Dick'})// disable auto-reloading the collectionthis.api.get().books().$post({name: 'Winnetou'},{reload: false})this.api.purgeAll()// will not reload the whole /books collection when we don't already know it// (at the point in time after the POST request has finished)this.api.post(awaitthis.api.get().$href('books'),{name: 'Harry Potter'})
The text was updated successfully, but these errors were encountered:
With POST requests, the semantic implication is often that we POST to a collection, and the response contains a newly created entity that has a new self URI. In this case, the collection in the store will not contain the new entity after the response has arrived.
We could consider adding a configurable option or flag to the
post
/$post
functions that allows to automatically reload the collection after the POST request has completed. This seems like a usual pattern that hal-json-vuex users would have to do manually otherwise, and it would be similar to the behaviour ofdelete
, where we reload any collection and entity that "know" the deleted entity.We should probably only reload the collection if it was loaded in the store already.
Thoughts on this? I'd imagine to use it like this:
The text was updated successfully, but these errors were encountered: