I tried to add a record to the database using a POST request in Node JS. I tried with the following,
<form action="/addDevice?deviceToken=" onsubmit="location.href = this.action + this.token.value; return false;" method="POST">
<input name="token" type="text" value="3456as7dssa65d56da78s9d9sd67"/><br>
<input type="submit" value="Add Device" class="btn btn-success"/><br>
</form>
in Node JS, I did,
app.post('/addDevice', function (req, res) {
device.addNewDevice(req.data.deviceToken, function (err, result) {
if (err) return res.json(err);
var msg = 'Added ' + result.affectedRows + ' rows.';
console.log('bode : ' + req.data.deviceToken);
// display all devices
device.getDevices(function (err, devices) {
if (err) return res.json(err);
res.render('device_view.html', {devices: devices, msg: msg});
});
});
});
When I'm running this I got the following error,
Cannot GET /addDevice?deviceToken=3456as7dssa65d56da78s9d9sd67
How can I fix this?
Thanks in Advance!