rethinkdb-example-nodejs icon indicating copy to clipboard operation
rethinkdb-example-nodejs copied to clipboard

getting parse error

Open ralyodio opened this issue 10 years ago • 3 comments

function* create(next) {
    try{
        // Parse the POST data
        var todo = yield parse(this); //this throws an error

https://github.com/rethinkdb/rethinkdb-example-nodejs/blob/master/todo-angular-koa/app.js#L64 This example throws an error for me.

screenshot 2015-05-21 03 29 55

I tried yield parse.json(this) and still not sure what the deal is. Same message.

Typically this means its not an object...but a string, and it indeed looks like JSON.stringify was ran on it.

ralyodio avatar May 21 '15 10:05 ralyodio

Hi @chovy. It looks like it's trying to parse a javascript object literal as json, and failing because the key isn't double quoted. I'll have to dig into this repo to fix it, which may take a while to get to.

In the meantime, if you happen to find the root cause and hack around it, I'd welcome any pull requests.

deontologician avatar May 21 '15 21:05 deontologician

I'll see if I can find the root cause in the meantime.

ralyodio avatar May 21 '15 21:05 ralyodio

Looks like co-body is for co not koa.

Reccommended use is to use koa-bodyparser: https://github.com/koajs/bodyparser

I will see if I can get it working tonight and let you know.

ralyodio avatar May 21 '15 23:05 ralyodio