-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
62 lines (52 loc) · 1.36 KB
/
Copy pathApp.js
File metadata and controls
62 lines (52 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import './App.css';
import { useEffect, useState } from 'react';
import MovieCard from './MovieCard.js';
const API_URL = 'http://www.omdbapi.com/?i=tt3896198&apikey=6222fe99';
const App = () => {
const [movies, setMovies] = useState([]);
const [searchTerm, setSearchTerm] = useState();
const searchMovie = async (title) => {
const response = await fetch(`${API_URL}&s=${title}`);
const data = await response.json();
setMovies(data.Search);
console.log(data.Search);
}
useEffect(() => {
searchMovie('green');
}, []);
return (
<div className='app'>
<h1 className='app-logo__title'>Jali Movie</h1>
<div className='search'>
<input
placeholder='Search for movies ...'
value={searchTerm}
onChange={(e) => {
setSearchTerm(e.target.value);
}}
/>
<img
src='./icons8-search.svg'
alt='search'
onClick={() => {searchMovie(searchTerm)}}
/>
</div>
{
movies.length > 0
? (
<div className='container'>
{
movies.map((movie) => (<MovieCard m={movie}/>)
)
}
</div>
) : (
<div>
<h4>NO MOVIE FOUND</h4>
</div>
)
}
</div>
);
}
export default App;