After trying several tutorials, I still couldn't resolve my issue.
This is where I am stuck in my code
const [data, setData] = useState([])
useEffect(() => {
getData()
}, [])
const getData = async () => {
fetch(`my Api`,{
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}
)
.then((response) => response.json())
.then((responseJson) => {
setData(responseJson.result);
console.log("log for Health professionals =====>", responseJson.result)
console.log("current_page at:::: =====>", responseJson.result.current_page)
})
.catch((error) => {
console.error(error);
});
}
const renderItem = ({item }) => {
return(
<View style={styles.itemRow} >
<Text style={{fontSize:20}}>{item.current_page}</Text>
<Text style={{fontSize:40}}>{item.result.current_page}</Text>
</View>
)
}
return (
<FlatList
style={styles.container}
data={data}
renderItem={renderItem}
keyExtractor={(item, index)=>index.toString()}
/>
)
};
Here is the response from my API };
I attempted to display the data from the API response on my mobile screen using pagination in React Native. Unfortunately, I was unable to see any results. Despite consulting various documentation, I was unable to find a solution.
My goal is to implement pagination with this API response in my React Native project.