I was fiddling with ExpressJS last night and found that given a simple code:
app.post('/contact', function(req, res, next) {
res.send('Congrats you have submitted the form');
});
I am able to respond to it correctly from the server side and actually send a blank document with the text "Congrats you have submitted the form".
However when I remove the "action" attribute and try to handle it with a javascript to perform a POST request like for example using the axios module it doesn't work:
axios.post('/contact', { data: { username: <user entered data>, password: { <user entered password> }});
I am not able to grab that data from the server side (inside express)
app.post('/contact', function(req, res, next) {
const username = res.data.username;
const password = res.data.password;
res.send('Login details: ' + username + ' / ' + password);
});