Skip to content

Commit

Permalink
Query-Parems
Browse files Browse the repository at this point in the history
  • Loading branch information
codingXpert committed Jun 29, 2022
1 parent f14f467 commit e5e9ac2
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions query-parems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const express = require('express');
const app = express();
const port = 8000;


app.get( '/' , (req , res) => {
res.send(`
<h1>Welcome , this is home page</h1>
<input type = "text" placeholder = "user name" value= "${req.query.name}" />
<button> Click Me </button>
<a href = '/about'> Go To About </a>
<h3>Accesing quary parems passed from the browser's URL as:- http://localhost:8000/?name=xyz </h3> ${req.query.name}
`);

console.log(req.query.name)
});

app.get('/about' , (req , res) => {
res.end(`<h1>Welcome , this is about page</h1>
const data = [
{
name:"vivek",
2 : "two"
} ,
{
"name":"vivek",
"addr" : "xyz"
}
]
<a href = '/' > Go To Home </a>
`)

console.log(req.body)


});

app.get('/help' , (req , res) => {
res.send('<h1>Welcome this is help page</h1>');
})



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);
});

0 comments on commit e5e9ac2

Please sign in to comment.