Express + Postman, req.body is empty

前端 未结 4 1885
醉梦人生
醉梦人生 2020-12-05 05:47

I know this has been asked multiple times, but I have been looking around and still can\'t find an answer to my problem.

Here is my code, I make sure to use and conf

4条回答
  •  囚心锁ツ
    2020-12-05 06:07

    Try this

     // create application/json parser
        app.use(bodyParser.json());
        // parse various different custom JSON types as JSON
        app.use(bodyParser.json({ type: 'application/*+json' }));
        // parse some custom thing into a Buffer
        app.use(bodyParser.raw({ type: 'application/vnd.custom-type' }));
        // parse an HTML body into a string
        app.use(bodyParser.text({ type: 'text/html' }));
        // parse an text body into a string
        app.use(bodyParser.text({ type: 'text/plain' }));
        // create application/x-www-form-urlencoded parser
        app.use(bodyParser.urlencoded({ extended: false }));
    

提交回复
热议问题