【发布时间】:2021-08-20 00:31:49
【问题描述】:
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
VS Code 中的 bodyParser 有删除线。
这里是新手!试图让 Spotify 克隆工作。我一直在试图弄清楚这里发生了什么以及如何解决它。任何见解都值得赞赏。谢谢!
【问题讨论】:
标签: body-parser
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
VS Code 中的 bodyParser 有删除线。
这里是新手!试图让 Spotify 克隆工作。我一直在试图弄清楚这里发生了什么以及如何解决它。任何见解都值得赞赏。谢谢!
【问题讨论】:
标签: body-parser
不要使用 bodyParser。它已被弃用,这就是为什么会有删除线。将您的行替换为:
app.use(express.json());
app.use(express.urlencoded({extended: false});
我假设您使用的是 express。如果没有,只需键入
npm i express 进入你的命令行,然后
const express = require('express');
在文件的顶部。
或
npm i @types/express 和 import express from 'express' 如果您使用的是打字稿
【讨论】: