Search code examples
falcorfalcor-router

Falcor Router set method


In my Router I have a set route like:

{
route: 'profile.["language"]',
async set(jsonGraph) {
  console.log(jsonGraph);
  // do async stuff w/database
  return {
          path: ['profile', 'language'],
          value: 'test'
        };
    }
}

The general idea with this route is to set the profile of a user. For testing purposes I just want to return the value 'test' on profile.language

The problem is I get a 500 internal server error with model.setValue('profile.language', 'english').then(done => console.log(done))

What's wrong with my route code? I can't find the problem...

ps: the async set(jsonGraph) is es7 await/async syntax.


Solution

  • After wasting a few hours on this, I found the solution:

    In my server.js

    import bodyParser from 'body-parser';
    app.use(bodyParser.urlencoded({extended: true}));
    

    Express couldn't parse the incoming request, that's why I got a 500 internal server error.

    Gotta love the fragility of javascript :)