JS 데이터 실습 _ OMDb API

LOOPY·2021년 8월 11일
0
  • OMDb(The Open Movie Database): 영화 정보 검색 기능 제공
    https://www.omdbapi.com/
  • Query String
  • axios: Promise based HTTP client for the browser and node.js ->Promise 객체 기반으로 브라우저나 node.js에서 사용하는 HTTP 요청 처리 패키지
    $ npm install axios
import axios from ‘axios’

function fetchMovies() {
  axios
    .get(‘https://www.omdbapi.com/?apikey=7035c60c&s=frozen’) // 주소 입력 시 http 말고 https 사용하기
    .then((res) => { // res는 response(응답) 또는 result(결과)
      console.log(res)
      const h1El = document.querySelector(‘h1’)
      const imgEl = document.querySelector(‘img’)
      h1El.textContext = res.data.Search[0].Title
      imgEl.src = res.data.Search[0].Poster
    })
}
profile
2년차 프론트엔드 개발자의 소소한 기록을 담습니다 :-)

0개의 댓글

관련 채용 정보