Reading Request data Using Express coming in from GET or POST --using the Express body-parser module
Example via extension of URI --- example URI/data (e.g. /read/Lynne)
this is a more "modern way" of building out GET requests where data in URI
>>> here we see what will happen when we run the code below
NOTE: THIS IS inside index.js (from routes but, you could put it in some controller code file instead that gets the forwarded request object |
Example with normal GET query string at endof URI --- example URI?n=v&n2=v2 (e.g. /readNameAndRespond?name=Lynne)
here the data is appended to the query string -- THIS IS WHAT HAPPENS FROM A GET FORM
>>> here we see what will happen when we run the code below
NOTE: THIS IS inside index.js (from routes but, you could put it in some controller code file instead that gets the forwarded request object
var express = require('express'); |
Example with POST request of a URI --- example sending POST data from a form
here the data is appended to the query string -- THIS IS WHAT HAPPENS FROM A GET FORM
>>> here we see what will happen when we run the code below
NOTE: THIS IS inside index.js (from routes but, you could put it in some controller code file instead that gets the forwarded request object var express = require('express'); |