주소?속성=값&속성=값&속성=값
- 주소: 서버의 주소, 웹 사이트 주소
속성=값
- apiKey=값을 통해 사용자 인증
- s=검색하고 싶은 영화
http://www.omdbapi.com/?apikey=[yourkey]&
http://www.omdbapi.com
→ 주소
apikey=[yourkey]
→ 속성=값
https://www.omdbapi.com/?apikey=7035c60c&s=frozen
- 영화 정보 불러오기
import axios from 'axios'
function fetchMovies() {
axios
.get('https://www.omdbapi.com/?apikey=7035c60c&s=frozen')
.then((response) => {
console.log(response)
}) // 메소드 체이닝
}
fetchMovies()
- 영화 제목과 포스터 불러오기
import axios from 'axios'
function fetchMovies() {
axios
.get('https://www.omdbapi.com/?apikey=7035c60c&s=frozen')
.then(res => {
console.log(res)
const h1El = document.querySelector('h1')
const imgEl = document.querySelector('img')
h1El.textContent = res.data.Search[0].Title
imgEl.src = res.data.Search[0].Poster
}) // 메소드 체이닝
}
fetchMovies()