Last active
March 24, 2019 00:20
-
-
Save lamecksilva/b93dddb9dff989dde99c2b6e6e403570 to your computer and use it in GitHub Desktop.
Primeira versão da rota de carros
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
const express = require('express'); | |
const router = express.Router(); | |
const Carro = require('../models/Carro'); | |
router.post('/novo', (req, res) => { | |
const novoCarro = new Carro({ | |
marca: req.body.marca, | |
modelo: req.body.modelo | |
}); | |
novoCarro | |
.save() | |
.then(result => { | |
res.json(result); | |
}) | |
.catch(error => { | |
res.status(500).json(error); | |
}); | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment