scalient / vuex-orm-json-api

A Vuex ORM adapter for JSON:API
Apache License 2.0
21 stars 4 forks source link

when there is a server error `this.response` is undefined #21

Closed mgiraldo closed 2 months ago

mgiraldo commented 2 years ago

version: 0.9.8

an API call that results in a server error (eg: 422 Unprocessable entity) will produce a vuex-orm-json-api error that cannot be handled by the application.

for example:

await this.$store.$db().model('my_model').jsonApi().create(someInvalidPayload)

produces no response object and therefore this line fails:

https://github.com/scalient/vuex-orm-json-api/blob/387471dba9baabd52fcc27c24c191f1ab561c2fe/src/json_api/Response.js#L20

renzodiaz commented 2 years ago

@carsomyr the response status is fine it should return 422, what we should create is create an interceptor error result in Axios to catch those kinds of errors (422, 401, 404) and handle them.

carsomyr commented 2 years ago

@renzodiaz Good point! I'll look into the undefined problem though.