LoginSignup
0
0

More than 1 year has passed since last update.

Express body-parserってなんなの?

Posted at

最近Expressを始めた。と言う人の中には
body-parserってなに?と言う人がいるんじゃないかと思いました。
私も最近までbody-parserが何か知りませんでした。
Expressの記事を読んでいると結構でてくるんですけどね...

結論

// 下記2つは全く一緒です。
app.use(express.json())

app.use(bodyParser.json())

Express v 4.16から標準でbodyParserが使えるようになりました。express.json()
書き方は違いますが、同じものを使っているので全く一緒らしいです。
今後はbodyParserを自前でインストールする必要はないです。
express v 4.16より下のバージョンを使うときのみインストールが必要です。

// もちろん下記も一緒です。
app.use(express.urlencoded({ extended: true }));

app.use(bodyParser.urlencoded({ extended: true }));

終わりに

私みたいにYoutubeやUdemyでExpressを学習をすると、最近はexpress.json()を使っているものが多いので、body-parserに触れることがなく、自分でネットの記事を漁るときに迷っちゃいますね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0