Code Monkey home page Code Monkey logo

Comments (7)

vabatta avatar vabatta commented on June 13, 2024

The problem is caused by body-parser of expressjs. It parses only Content-Type: application/json and NOT Content-Type: application/vnd.api+json.

from fortune.

gr0uch avatar gr0uch commented on June 13, 2024

I think you described the problem correctly in #59, the issue is that it expects an array not an object, this is due to churn in the specification.

from fortune.

vabatta avatar vabatta commented on June 13, 2024

Yes, really the two problems (content-type and proxing resouces to array) aren't related.

from fortune.

ferdegje avatar ferdegje commented on June 13, 2024

@vabatta did you find a solution to this issue? I'm facing the same and cannot figure out what I am doing wrong.

from fortune.

gr0uch avatar gr0uch commented on June 13, 2024

@ferdegje The solution is to wait until 1.0.0-alpha.1 is released ;)

If you haven't noticed, the master branch has been stagnant for a while since I'm working on the rewrite branch. I should make the notice in the readme bigger, or just hurry up and ship 1.0 alpha.

from fortune.

ferdegje avatar ferdegje commented on June 13, 2024

@vabatta found the solution to your issue, the body of your request is wrong.

You send:
{"pets":
{
"name": "Dog",
"age": 18
}
}

But you should send:
{"pets":
[
{
"name": "Dog",
"age": 18
}
]
}

Otherwise it will create the issue you have documented

from fortune.

vabatta avatar vabatta commented on June 13, 2024

@ferdegje as reported on json api, you could have an array of resource objects or just a single object rapresenting the model. Fortunejs respond always with an array, and this cause the error.
I fixed just proxing everything to an array, adding this after lib/route.js#L232:

if (typeof resources !== Array) resources = [resources];

from fortune.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.