Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const app = express();
- var bodyParser = require('body-parser');
- //not sure if i need urlencoded when just sending data from client
- // app.use(bodyParser.urlencoded({ extended: false }))
- // app.use(bodyParser.urlencoded({ extended: true}));
- // app.use(bodyParser.urlencoded());
- app.use(bodyParser.json());
- const port = process.env.PORT || 8000;
- const Cat = require('./Cat');
- const Dog = require('./Dog');
- app.route('/animals')
- .get(function (req, res) {
- console.log(res.body);
- res.send({ Cat, Dog });
- })
- .patch(function (req, res) {
- console.log('patch is working!');
- console.log(req.body);
- })
- app.listen(port, () => console.log(`Listening on port ${port}`));
- fetch('/animals', { method: 'PATCH', body: {name: 'kitten'} })
Add Comment
Please, Sign In to add comment