git init
git add .
git commit -m 'init project'
Git Hub에서 프로젝트용 Repository 생성
VS Code에서 remote 등록
git remote add origin 경로
git push origin main
git checkout -b develop
git push origin develop > 원격에 develop 브랜치 생성
<script>
document.querySelector('#reqBtn').addEventListener('click', function(){
var xhr = new XMLHttpRequest();
var url = 'https://apis.data.go.kr/B551011/GoCamping/searchList'; /*URL*/
var queryParams = '?' + encodeURIComponent('serviceKey') + '='+'nHYvwaA5iMdJN%2BZfRIwpkLrcYSbqND87jXVtes2Z6I7kb5%2F8Ycv1UCLzedNfTfWQ%2FVoOtadIC9WpwTLtTnukPA%3D%3D'; /*Service Key*/
queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /**/
queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('10'); /**/
queryParams += '&' + encodeURIComponent('MobileOS') + '=' + encodeURIComponent('ETC'); /**/
queryParams += '&' + encodeURIComponent('MobileApp') + '=' + encodeURIComponent('AppTest'); /**/
queryParams += '&' + encodeURIComponent('_type') + '=' + encodeURIComponent('json'); /**/
queryParams += '&' + encodeURIComponent('keyword') + '=' + encodeURIComponent('천안'); /**/
xhr.open('GET', url + queryParams); //GET, POST, PUT, DELETE 요청 방식
console.log(url + queryParams);
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
console.log(this);
// document.getElementById('result').textContent = 'Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText;
document.getElementById('result').textContent = this.responseText;
let jsonObj = JSON.parse(this.responseText);
console.log(jsonObj);
for(let i=0; i<jsonObj.response.body.items.item.length; i++) {
console.log(jsonObj.response.body.items.item[i].facltNm);
console.log(jsonObj.response.body.items.item[i].addr1);
}
// console.log(jsonObj.response.body.items.item[0].facltNm);
//JSON.stringify -> Objecct -> JSON 텍스트
//JSON.parse -> JSON 텍스트 -> Object
}
};
xhr.send(); //요청을 보냄
});
</script>