mergeConfig.js:92 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at mergeConfig (mergeConfig.js:92:24)
at Axios.request (Axios.js:39:12)
at Axios.<computed> [as get] (Axios.js:129:17)
at Function.wrap [as get] (bind.js:9:15)
at HTMLButtonElement.searchMovies (App.svelte:11:27)
mergeConfig @ mergeConfig.js:92
request @ Axios.js:39
Axios.<computed> @ Axios.js:129
wrap @ bind.js:9
searchMovies @ App.svelte:11
input 창에 lion을 검색했을 때 이러한 오류가 떠서 질문드립니다.
현재 코드
<script>
import axios from "axios";
let apikey = "0000000";
let title = "";
let movies = null;
let error = null;
let loading = false;
async function searchMovies() {
const res = await axios.get(
`http://www.omdbapi.com/?apikey=${apikey}&s=${title}`,
);
console.log(res);
movies = res.data.Search;
}
</script>
<input bind:value={title} />
<button on:click={searchMovies}>검색</button>
{#if loading}
<p style="color: royalblue">Loading...</p>
{:else if movies}
<ul>
{#each movies as movie}
<li>{movie.Title}</li>
{/each}
</ul>
{:else if error}
<p style="color: red;">{error.message}</p>
{/if}