01. hello express
get 요청의 query 와 post 요청의 body 를 json으로 reponse 되게 구현하여주세요.
HINT1: get 요청은 client로 부터 전송된 request query를 사용합니다.
HINT2: post 요청은 client로 부터 전송된 request body를 사용합니다.
HINT3: express에서 query 와 body를 가져오는 방법은 유사합니다.
요구 사항
- url은 hello 로 설정해주세요. ('/hello')
- /hello url에 get 요청과 post 요청을 만들어주세요.
- get 요청의 query 로 world 가 들어오게 만들어주세요.
- post 요청의 body 로 world 가 들어오게 만들어주세요.
- 들어온 world 값을 응답으로 내보내주세요.
- 응답 키 이름은 message 로 해주세요.
요청, 응답 인터페이스
// get 요청
http://localhost:10010/hello?world=string
// 응답
200 {
"message": string
}
// post 요청
http://localhost:10010/hello
body {
"world": string
}
// 응답
200 {
"message": string
"message": string
풀이
markdown에서 문제 확인 후, app.js로 가서 풀기
replit에서 shell은 nmp run test로 결과 확인용 (npm run test : 구현 결과 보기)
replit 에서 ctrl^c : 명령어 취소
'Wecode - Foundation 1 (부트캠프) > Foundation 1 마무리 퀴즈' 카테고리의 다른 글
Foundation 1- replit quiz 5 (0) | 2023.09.06 |
---|---|
Foundation 1 - quiz 4. replit [Node.js] (0) | 2023.09.05 |
Foundation 1- quiz 3. replit [Node.js] (0) | 2023.09.05 |
Foundation 1- quiz 2 replit (0) | 2023.09.05 |