Reputation: 5123
This is how I am using the package:
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
This is the body of my request:
{
name: "jay",
price: "12"
}
This is how I am extracting the body:
const name = req.body.name;
const price = req.body.price;
But both name
and price
returned undefined
.
EDITED:
According to VS Code, this package is deprecated. But it should still work, no?
Upvotes: 0
Views: 154
Reputation: 56
the request body should be JSON so property names should be in quote signs
{
"name": "jay",
"price": "12"
}
Upvotes: 1