Skip to content

Instantly share code, notes, and snippets.

@korrio
Created November 12, 2014 00:39
Show Gist options
  • Save korrio/34c0e92db353bace9a94 to your computer and use it in GitHub Desktop.
Save korrio/34c0e92db353bace9a94 to your computer and use it in GitHub Desktop.
POST Method (ต.ย. วิธี parse ค่า json ที่ส่งมาจาก android)
app.post('/api/products', function (req, res){
var product;
console.log("POST: ");
console.log(req.body);
product = new ProductModel({
title: req.body.title,
description: req.body.description,
style: req.body.style,
});
product.save(function (err) {
if (!err) {
return console.log("created");
} else {
return console.log(err);
}
});
return res.send(product);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment