Guest User

Untitled

a guest
Jan 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. const express = require('express');
  2. const app = express();
  3. var bodyParser = require('body-parser');
  4.  
  5. //not sure if i need urlencoded when just sending data from client
  6. // app.use(bodyParser.urlencoded({ extended: false }))
  7. // app.use(bodyParser.urlencoded({ extended: true}));
  8. // app.use(bodyParser.urlencoded());
  9. app.use(bodyParser.json());
  10. const port = process.env.PORT || 8000;
  11.  
  12. const Cat = require('./Cat');
  13. const Dog = require('./Dog');
  14.  
  15. app.route('/animals')
  16. .get(function (req, res) {
  17. console.log(res.body);
  18. res.send({ Cat, Dog });
  19. })
  20. .patch(function (req, res) {
  21. console.log('patch is working!');
  22. console.log(req.body);
  23. })
  24.  
  25. app.listen(port, () => console.log(`Listening on port ${port}`));
  26.  
  27. fetch('/animals', { method: 'PATCH', body: {name: 'kitten'} })
Add Comment
Please, Sign In to add comment