HTTP DELETE verb in Node.JS HTTP DELETE verb in Node.JS express express

HTTP DELETE verb in Node.JS


Hopefully this can help:

  • Enable logging as your first middleware to make sure the request is coming in:

    app.use(express.logger());

  • Use the methodOverride() middleware:

    app.use(express.bodyParser());

    app.use(express.methodOverride()); // looks for DELETE verbs in hidden fields

  • Create a .del() route:

    app.del('/api/1.0/entry', function(req, res, next) { ... });


PUT and DELETE values for type setting are not supported by all browsers:

See documentation http://api.jquery.com/jQuery.ajax/

You can use POST type including data:{_method:'delete'} in ajax request:

$.ajax({    data:{_method:'delete'},    url: '/api/1.0/entry',    type: 'POST'}).done(function(res){    var row = $(this).parentsUntil('tbody');    row.slideUp();});