기록

Node.js 기능 및 Error 모음

1. UTF-8 to EncodeURL
encodeURIComponent(); // 자바 제공 함수

var location = '서울'
var encodedURL = encodeURIComponent(location);

2. xml to JSON
convert.xml2json(body, {compact: true, spaces: 4}); // request로 받은 xml을 json으로

request(urlData, function (error, response, body)
{
var xmlToJson = convert.xml2json(body, {compact: true, spaces: 4});
const obj = JSON.parse(xmlToJson);

3. URL 조합
let urlData = getAreaRiseSetInfo_url;
urlData += '?serviceKey=' + AreaRiseSetInfo_ServiceKey;
urlData += '&locdate=' + locdate;
urlData += '&location=' + encodedURL;

댓글

이름만 적고 남길 수 있어요