I got a typeerror while trying to render the website contents in my App
import React ,{useState,useEffect} from "react";
import { FlatList, StyleSheet, Text, View } from 'react-native';
export default function Home(){
const [data,setData]= useState([{}]);
useEffect(()=>{
fetch('https://corona.askbhunte.com/api/v1/data/nepal')
.then((response) => response.json())
.then((data)=> setData(data))
.catch((error) => alert(error));
},[])
return(
<View>
<FlatList
data={data}
keyExtractor={({ id }, index) => id}
renderItem={({ item }) => (
<Text>{item.tested_positive}</Text>
)}
/>
</View>
)
}
I want to fetch data from a website in my app. The screen renders but it does not fetch any data.
<Text>{item.tested_positive}</Text>.