Skip to content

Instantly share code, notes, and snippets.

@lamecksilva
Last active March 24, 2019 00:20
Show Gist options
  • Save lamecksilva/b93dddb9dff989dde99c2b6e6e403570 to your computer and use it in GitHub Desktop.
Save lamecksilva/b93dddb9dff989dde99c2b6e6e403570 to your computer and use it in GitHub Desktop.
Primeira versão da rota de carros
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