0

In nodejs applications i found method-override module and the project which i am studing contains this code

var methodOverride=require('method-override');

and after creating rest server

rest.use(methodOverride())

It seems like it is a middleware. But my question is there we are not passing any arguments. Then what actually it does ?

Devdutta Goyal
  • 985
  • 2
  • 11
  • 27
  • 1
    http://stackoverflow.com/a/8378414 This is used to simulate `put` and `delete` methods like `app.put(` `app.delete`, which are otherwise unavailable. – Talha Awan Apr 01 '17 at 11:38

1 Answers1

1

From method-override README:

Lets you use HTTP verbs such as PUT or DELETE in places where the client doesn't support it.

Usage: methodOverride(getter, options)

You are calling this same function, but the defaults for getter and options are being applied. Which are:

getter: X-HTTP-Method-Override

options: ['POST']

It will be easier if you simply check the API next time.

Usually typing www.npmjs.com/package/<name> takes you there. (www.npmjs.com/package/method-override in this case)

Sergio Carneiro
  • 3,726
  • 4
  • 35
  • 51