body-parser 用法

 

一、下載 body-parser 模塊  :   npm install body-parser  express

 

二、require body-parser 模塊(引入),並用一個變量接收(此處栗子變量爲 bodyparser)npm

 

三、將 bodyparser 註冊爲中間件app

 

 

const express = require('express') // 在此處 require body-parser 模塊
const bodyparser = require('body-parser') const app = express() app.listen(3001, () => console.log('app is running...')) // 在此處 use 這個 bodyparser 中間件
app.use(bodyparser.urlencoded({ extended: false }))
相關文章
相關標籤/搜索