I get JSON data from my client and want to save it to Stormpaths custom data using node.js with express.js:
I've got my basic post route:
app.post('/post', stormpath.loginRequired, function(req, res){
var data = req.body;
res.locals.user.customData.test = data;
res.locals.user.customData.save();
});
I basically want to overwrite the given data in customData.test and than save it, but right now it's adding the given data to customData.test.
How do i fix that?
It sounds like you want to put the data properties directly onto the custom data object? I'd suggest using an "extend" function that will copy the
data
properties onto thecustomData
object.For example using Underscore extend:
I also really like xtend