I noticed this issue while testing out the code today. When you do a post to user/talk/add
to add a set of talks by an user. The expected response is a JSON Object of the form
But the response only contained the "value" and the "key" part was missing due to which an exception was being thrown at the client end. For example, when I added a single talk, I got the following response
[
{
"__v": 0,
"user": "5533c42aa3242ada7e421407",
"created_at": 1429458055809,
"needsTools": true,
"needsProjector": true,
"hasCoPresenters": true,
"duration": "bhvfm",
"event": "Unconference",
"type": "Session",
"notes": "cvff\n",
"title": "gdsyjvch",
"_id": "5533cc87a3242ada7e421424"
}
]
{
"talks": [
{
"__v": 0,
"user": "5533c42aa3242ada7e421407",
"created_at": 1429459061916,
"needsTools": true,
"needsProjector": true,
"hasCoPresenters": true,
"duration": "bhvfm",
"event": "Unconference",
"type": "Session",
"notes": "cvff\n",
"title": "gdsyjvch",
"_id": "5533d075df56c90b075bf636"
}
]
}
I spent sometime on how to correct the issue and made the patch which is present below.
diff --git a/routes/users.js b/routes/users.js
index 5555740..9540952 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -100,8 +100,9 @@ router.post('/talk/add', global.isAuthenticated, function(req, res){
error : error
});
}
- res.json(results);
- });
+ res.json({
+ 'talks' : results
+ });
} catch(err){
res.status(500);
Kindly review the patch and apply it, do let me know when it is done.