beauby / jsonapi-datastore

JavaScript client-side JSON API data handling made easy.
MIT License
195 stars 40 forks source link

Add payload error parsing #30

Open buren opened 8 years ago

buren commented 8 years ago

First of all thank you for this package :+1: :star:

This is by no means ready.. Just thought it could act as a starting point for discussing how errors could be handled.

With this approach every time a POST or PATCH response it synced the consumer must write something like this..

var article = store.sync(payload);
if (article.errors) {
  // error handling
} else {
  // handle successful response
}

@beauby what do you think? Should errors be handled in some other way?

beauby commented 7 years ago

Hi @buren – sorry for the super-long delay. I really like the idea, although the API would have to be a bit different as the spec does not, AFAIK, forbid a field to be named errors, which would create a name clash.