I have the following code in my node app:
// POST route
app.post('/bb', async (req, res) => {
try {
// Assuming you're receiving JSON data in the request body
const newData = await req;
// Process the new data here
console.log('Received new data:', newData);
res.status(200).json({ message: 'Data received successfully' });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.listen(3000, () => console.log('Server started on port 3000'));
When I try to send it some json with Postman I get:
Cannot POST /bb%0A
What am I doing wrong?
2
Answers
look here
I see the arrow in the last URL
http://localhost:3000/bb[arrow]
in the postman, so you may delete that arrow and try again.