What does Connect.js methodOverride do?

前端 未结 1 1822
我寻月下人不归
我寻月下人不归 2020-12-12 11:25

The Connect.js very terse documentation says methodOverride

Provides faux HTTP method support.

What does that mean?

1条回答
  •  盖世英雄少女心
    2020-12-12 12:00

    • If you want to simulate DELETE and PUT, methodOverride is for that.
    • If you pass in the _method post parameter set to 'delete' or 'put', then you can use app.delete and app.put in Express instead of using app.post all the time (thus more descriptive, verbose):

    Backend:

    // the app
    app.put('/users/:id', function (req, res, next) {
      // edit your user here
    });
    

    Client logic:

    // client side must be..
    
    ...

    0 讨论(0)
提交回复
热议问题