The problem is that the data passed via POST that is accessed with
req.body is being added in a single string.
This is what I get:
"data": "{\"hello\": \"world\", \"number\": 23}"
But I want this:
"data": "{
"hello": "world",
"number": 23
}
Here is my update function:
{
"_id": "_design/time2id",
"updates": {
"u": "function (doc, req) {var doc = new Object();doc._id =
String(Math.round(new Date().getTime()/1000));doc.data=req.body;return
[doc, \"Done\"];}"
}
}
I call it like this:
curl -k -u "uiim...@sharklasers.com:password123" -X PUT
https://zuhqtr5.couchappy.com/testupdates/_design/time2id/_update/u/
-d '{"hello": "world", "number": 23}' -H "Content-Type:
application/json"