Last active
May 14, 2017 18:51
-
-
Save gorkamu/c20b8a948bfb6891c7125f75f83ede8b to your computer and use it in GitHub Desktop.
Ejemplo de método POST en una API REST con Node.js
This file contains hidden or 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
function saveAlbum(req, res){ | |
var album = new Album(); | |
var params = req.body; | |
album.title = params.title; | |
album.band = params.band; | |
album.genre = params.genre; | |
album.year = params.year; | |
album.save(function(err, albumStored){ | |
if(err){ | |
res.status(500).send({message:'Error al guardar el album'}); | |
}else{ | |
res.status(200).send({album: albumStored}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment