I do not know whats going on here and tried to fix it for a few hours now.
So I am posting the data to
now in my root folder I have node file index.js
I am trying to retrieve the posted values
// grab the packages we need
var express = require('express');
var app = express();
var port = process.env.PORT || 8080;
// start the server
app.listen(port);
console.log('Server started! At http://localhost:' + port);
var bodyParser = require('body-parser');
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
// POST http://localhost:8080/api/users
// parameters sent with
app.post('/api/data', function(req, res) {
var user_id = req.body.id;
var token = req.body.token;
var geo = req.body.geo;
res.send(user_id + ' ' + token + ' ' + geo);
});
However when I start the node server and navigate to either
or
I simple get : Cannot Get
What am I doing wrong ?
via Beep
No comments:
Post a Comment