devour-js / devour-client

Don't just consume your JSON API, Devour it...
https://www.npmjs.com/package/devour-client
ISC License
429 stars 89 forks source link

Content-Type header not set #163

Closed Truemedia closed 5 years ago

Truemedia commented 6 years ago

Hi, Just found this library today and I'm having an issue connected this to a JSONAPI server (fortune JS using mongo adapter).

The problem is when I make a request from devour I get this error back from the server: NotAcceptableError: The serializer for "application/vnd.api+json" does not exist.

Apparently this is caused by the request not having a content type header. I can indeed see that chrome is not sending that header when making the request (doing a find with a single ID).

I looked inside the devour lib and can see you do set them, but then noticed this is an issue with axios the dep you are using for formatting and sending requests.

Apparently axios only applies this header if there is any content set beforehand. So I think the library needs tweaking to set the content type header after setting the data (in theory?).

Auspicus commented 5 years ago

This sounds like an issue on the serverside. The content-type application/vnd.api+json is part of the JSONAPI spec. https://jsonapi.org/format/#content-negotiation-clients