Matthew Harwood Matthew Harwood - 24 days ago 7x
AngularJS Question

Why does angular-fullstack use both put and patch requests for express?

I found Difference between put and patch. I kind of understand teh difference after reading. It's still hazy.

My question is:
Why does Yeoman generator: angular fullstack use

router.put('/:id', controller.update);
router.patch('/:id', controller.update);

In there index.js files of their server.collections?

What's the purpose of having both? Moreover, How would I use one vs the other?

'use strict';

var express = require('express');
var controller = require('./thing.controller');

var router = express.Router();

router.get('/', controller.index);
router.get('/:id',;'/', controller.create);
router.put('/:id', controller.update);
router.patch('/:id', controller.update);
router.delete('/:id', controller.destroy);

module.exports = router;

server controller

// Updates an existing thing in the DB.
exports.update = function(req, res) {
if(req.body._id) { delete req.body._id; }
Thing.findById(, function (err, thing) {
if (err) { return handleError(res, err); }
if(!thing) { return res.send(404); }
var updated = _.merge(thing, req.body); (err) {
if (err) { return handleError(res, err); }
return res.json(200, thing);


They are just different http verbs. Reading

Requests that the enclosed entity be stored under the supplied URI. If the URI refers
to an already existing resource, it is modified; if the URI does not point to an existing
resource, then the server can create the resource with that URI.[15]

Applies partial modifications to a resource.[18]