rethinkdb / rethinkdb-example-nodejs

136 stars 99 forks source link

getting parse error #15

Open ralyodio opened 9 years ago

ralyodio commented 9 years ago
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.

deontologician commented 9 years ago

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.

ralyodio commented 9 years ago

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

ralyodio commented 9 years ago

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.