(16) express 모듈 사용-⑦ 쿼리스트링 응용

2019. 4. 3. 14:59 JavaScript BackEnd/Node.js, Express

app.js 에 추가한 후 url: 127.0.0.1:3000/topic으로 접근해보자.


============================================================

app.js 

++ 붙여넣기


app.get('/topic',function(req, res){

var topics =[

'javascript is the client language'

,'nodejs is the server side javascript'

,'express is a module of extra modules'

];

var output = `

<a href = "/topic?id=0">Java Script</a><br/>

<a href = "/topic?id=1">Node js</a><br/>

<a href = "/topic?id=2">Express</a><br/>

${topics[req.query.id]}

`;

res.send(output);

});

========================================================

127.0.0.1:3000/topic 으로 접근


Java Script 클릭


Node js 클릭




Express 클릭






출처: https://sourceflower.tistory.com/16?category=561762 [소스플로우]