Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 1.33 KB

OMDb API.md

File metadata and controls

70 lines (50 loc) · 1.33 KB

OMDb API

OMDb API에 대한 정보

Query String

주소?속성=값&속성=값&속성=값

  • 주소: 서버의 주소, 웹 사이트 주소
  • 속성=값
    1. apiKey=값을 통해 사용자 인증
    2. s=검색하고 싶은 영화
http://www.omdbapi.com/?apikey=[yourkey]&

http://www.omdbapi.com → 주소

apikey=[yourkey] → 속성=값

https://www.omdbapi.com/?apikey=7035c60c&s=frozen

axios

GitHub - axios/axios

  • 영화 정보 불러오기
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()