Created
November 12, 2014 00:39
-
-
Save korrio/34c0e92db353bace9a94 to your computer and use it in GitHub Desktop.
POST Method (ต.ย. วิธี parse ค่า json ที่ส่งมาจาก android)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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