Message from JavaScript discussions

May 2017

— Javascript never ceases to impress me

— 

var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.post('/post',function(request,response){
console.log(request.body) //you will get your data in this as object.
})

— Thats more like it

— It parses the formdata into an object

— Oh ok nice

— Then gives it to the callback in request

— Do you know a library that can preformat form data into json on the clients side? By chance?

— → Jquery

— Nice.

— You can send it by using JSON.stringify

— Https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

— Then simply parse it back into a JS object on the server