Calculator App Q. How to get form data in express server? Ans: Use Body-Parser Module to get html form data into the server. Example: app . get ( "/" , function ( req , res ){ res . sendFile ( __dirname + "/index.html" ); }); app . post ( "/" , function ( req , res ){ res . send ( "Data sent !" ); }); If we wanna try to get from data we get form values in PayLoad section in Chrome Developer Tool Here we can see : firstNumber : 2 secondNumber: 6 these numbers are bound to forms input fields To use these information in server We Need BodyParser > npm install body-parser Then include it in your code: > con...
Comments
Post a Comment