最終更新:2022-09-16 (金) 13:59:53 (581d)
req.body
Top / req.body
Contains key-value pairs of data submitted in the request body.
https://expressjs.com/en/api.html#req.body
メモ
- By default, it is undefined, and is populated when you use body-parsing middleware such as express.json?() or express.urlencoded?().
app.use(express.json()) // for parsing application/json app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded
Content-Type別
express.json?() for parsing application/json express.urlencoded?() for parsing application/x-www-form-urlencoded Multer for multipart/form-data
Multer
- multer.diskStorageのdestinationとかの中だとデコードされない
- The default express body-parser cannot work with multipart/form-data, hence we use multer to parse form-data which is accessible inside your upload function.
- https://stackoverflow.com/questions/39589022/node-js-multer-and-req-body-empty