// HTML 에 AXIOS CDN 연결 후 작업
function fetchMovies(title) {
const OMDB_API_KEY = '7035c60c'
return new Promise(async (resolve, reject) => {
try {
const res = await axios.get(`https://omdbapi.com?apikey=${OMDB_API_KEY}&s=${title}`)
resolve(res)
} catch(error) {
console.log(error.message)
reject('malza?')
}
})
}
async function test() {
try {
const res = await fetchMovies('frozen')
console.log(res)
} catch(error) {
console.log(error)
}
}
test()
function malza() {
fetchMovies('terminate')
.then((res) => console.log(res))
.catch(res => console.log(res))
}
malza()
이행(fulfilled) : 연산이 성공적으로 완료됨 ==> resolve
거부(rejected) : 연산이 실패함 ==> reject
대기(pending) : 비동기 함수가 실행되서 이행이나 거부가 되기 직전까지의 내용