From e5e9ac256eefb2b414fcced74af4c6a46f7d41ff Mon Sep 17 00:00:00 2001 From: Vivek Date: Wed, 29 Jun 2022 17:55:14 +0530 Subject: [PATCH] Query-Parems --- query-parems.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 query-parems.js diff --git a/query-parems.js b/query-parems.js new file mode 100644 index 0000000..8594e51 --- /dev/null +++ b/query-parems.js @@ -0,0 +1,51 @@ +const express = require('express'); +const app = express(); +const port = 8000; + + +app.get( '/' , (req , res) => { + res.send(` +

Welcome , this is home page

+ + + Go To About +

Accesing quary parems passed from the browser's URL as:- http://localhost:8000/?name=xyz

${req.query.name} + `); + + console.log(req.query.name) +}); + +app.get('/about' , (req , res) => { + res.end(`

Welcome , this is about page

+ const data = [ + { + name:"vivek", + 2 : "two" + } , + + { + "name":"vivek", + "addr" : "xyz" + } + ] + Go To Home + `) + + console.log(req.body) + + +}); + +app.get('/help' , (req , res) => { + res.send('

Welcome this is help page

'); +}) + + + +app.listen(port , (err) => { + if(err){ + console.log(`Error while connecting to server ${err} on PORT ${port}`); + return; + } + console.log('Server running on the port' , port); +}); \ No newline at end of file