Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
Header.svelte
Movie.svelte
Search.svelte
<script>
import Header from './Header.svelte';
import Movie from './Movie.svelte';
import Search from './Search.svelte';
import { onMount } from 'svelte'
const MOVIE_API_URL = "https://www.omdbapi.com/?s=man&apikey=4a3b711b"; // you should replace this with yours
let query = '';
let movies = [];
let loading = null;
let errorMessage = '';
onMount(async () => {
fetch(MOVIE_API_URL)
.then(response => response.json())
.then(jsonResponse => {
if (jsonResponse.Response === "True") {
movies = jsonResponse.Search;
} else {
errorMessage = jsonResponse.Error;
}
});
});
function searchMovies() {
loading = true;
fetch(`https://www.omdbapi.com/?s=${query}&apikey=4a3b711b`)
.then(response => response.json())
.then(jsonResponse => {
if (jsonResponse.Response === "True") {
movies = jsonResponse.Search;
loading = false;
} else {
errorMessage = jsonResponse.Error;
loading = false;
}
});
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */