카테고리 없음
[자바 스크립트] http의 응답 본문 요청 모듈을 사용하여 요청 받기
필살기쓰세요
2021. 1. 21. 17:24
때때로 응답이
String
.
JSON
객체 에서 구문 분석 한 다음 사용하십시오.
request({
url: 'http://custom-url',
method: 'GET'
}, function(err, response, body) {
if (body && typeof body == "string") {
body = JSON.parse(body);
}
console.log("Got Response : " + respnose.statusCode);
console.log("Body : " + body);
console.log("name is " + body.name);
})
출처
https://stackoverflow.com/questions/39917019