I'm trying to write a file by passing it as a json string to an ExpressJS POST:
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 was saved!");
});
});
But when I'm trying to pass, it turns up a 404:
POST http://localhost:5000/filewrite/%7B%22db%22:[%7B%22ID%22:%2211111111%22,%22job%22:%2222222222]%7D 404 (Not Found)
How do I need to define the POST route to accept parameters?