JS, jQuery

fetch()

닉네임이없어서아무거나지음 2023. 1. 5. 00:07
반응형

1. 의미

- fetch 매서드는 JavaScript에서 서버로 네트워크 요청을 보내고 응답을 받을 수 있도록 해주는 매서드이다.

 

2. 예시

fetch('html').then(function(response){ // 서버에게 html이라는 파일을 요청
    response.text().then(function(text){
        alert(text); // 서버가 응답해 준 데이터가 text에 저장된다.
    })
})

 

3. 참고

https://goodteacher.tistory.com/540

반응형