deChristo
deChristo

Reputation: 1878

Express method-override in node.js

In a node application at server.js file, what is the difference between use:

app.use(methodOverride());

or use:

app.use(methodOverride('X-HTTP-Method-Override'));

Both of them works. I just want to know if there is any difference between.

Thanks in advance.

Upvotes: 1

Views: 2141

Answers (1)

cejast
cejast

Reputation: 1007

From the docs: https://github.com/expressjs/method-override

Essentially, it will retrieve your method override from the X-HTTP-Method-Override header by default. Specifying it makes no difference.

If you were to retrieve your method override from an alternative header, X-Foo-Bar, you would use app.use(methodOverride('X-Foo-Bar'));.

If you were to retrieve your method override from a query string, foo=PUT, you would omit the X- prefix, e.g. app.use(methodOverride('foo'));

Upvotes: 2

Related Questions