Skip to content

Instantly share code, notes, and snippets.

@riccardopirani
Last active December 28, 2017 16:23
Show Gist options
  • Save riccardopirani/b06b98ab9b41c70170e2a8e41bf1e13d to your computer and use it in GitHub Desktop.
Save riccardopirani/b06b98ab9b41c70170e2a8e41bf1e13d to your computer and use it in GitHub Desktop.
how to extrapolate the parameters of the Json request
//Correctly Version
//Import the necessary libraries/declare the necessary objects
var express = require("express");
var myParser = require("body-parser");
var app = express();
//Login
app.use(myParser.urlencoded({extended : true}));
app.post("/login", function(request, response) {
var data = JSON.parse(Object.keys(request.body)[0]);
var username = data.Username;
var password = data.Password;
console.log(username);
console.log(password);
});
//Application Listen on Port
app.listen(3000,function(){
console.log("Application Server Start on Port: 3000");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment