I am attempting to save a file by sending it as a JSON string through an ExpressJS POST request:
app.post('/filewrite/', (req, res) => {
const fs = require('fs');
console.log(req.body);
fs.writeFile("./db/test.json", req.body, function(err) {
if(err) {
return console.log(err);
}
console.log("The file has been saved!");
});
});
However, when I try to send the data, I receive a 404 error message:
POST http://localhost:5000/filewrite/%7B%22db%22:[%7B%22ID%22:%2211111111%22,%22job%22:%2222222222]%7D 404 (Not Found)
What changes do I need to make in defining the POST route to accept parameters correctly?