XMLHttpRequest를 이용 test.html의 데이터 받아오기 (Nodejs에서 쓰려면 npm으로 설치해야 한다.)
let request = new XMLHttpRequest();
request.open('GET', 'test.html');
console.log(request.responseText);
request.send();
Fetch API를 이용해 test.html의 데이터 받아오기
fetch('test.html') //명시하지 않으면 GET방식으로 통신한다
.then(function(response) {
console.log(response.text());
})
XMLHttpRequest 참조 : https://developer.mozilla.org/ko/docs/Web/API/XMLHttpRequest
XMLHttpRequest 레퍼런스 : https://xhr.spec.whatwg.org/
Fetch API 참조 : https://developer.mozilla.org/ko/docs/Web/API/Fetch_API
Fetch API 레퍼런스 : https://fetch.spec.whatwg.org/
'프로그래밍 > JS+Node.js' 카테고리의 다른 글
[Node.js] 연습1 : 중복 파일 검색 후 특정 폴더로 이동 (0) | 2019.07.05 |
---|---|
[Node.js] SQLite3 : 인 메모리 데이터베이스(In-Memory Databases)로 사용하기 (0) | 2019.07.04 |
[Node.js] SQLite3 : run() 예외 처리 (0) | 2019.06.12 |
[Node.js] 해시값 계산 : Crypto 모듈 (0) | 2019.06.12 |