-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
47 lines (36 loc) · 940 Bytes
/
App.tsx
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
import { View, Text } from 'react-native'
import React, { useEffect, useState } from 'react'
import { searchMovie, upcomingMovies } from './src/api/apicall';
const App = () => {
const [upcomingMovies2, setUpcomingMovies2] = useState<any>(undefined)
const getUpcomingMovies = async () =>{
try{
await fetch(upcomingMovies).then(res=>res.json()
).then(res=>{return res}
)
}
catch(e:any){
console.log(e.message);
}
}
useEffect(()=>{
try{
fetch(upcomingMovies).then(res=>res.json()
).then(res=>{setUpcomingMovies2(res.results);
}
)
}
catch(e:any){
console.log(e.message);
}
},[])
console.log(upcomingMovies2);
return (
<View>
<Text>{upcomingMovies2[0].title}</Text>
<Text>{upcomingMovies2[0].release_date}</Text>
<Text>{upcomingMovies2[0].overview}</Text>
</View>
)
}
export default App