Hello i recently just started learning react native. I am now trying to fetch data from a wordpress api with the following code with this exact api address but nothing loads up.
import React from 'react';
import { FlatList, ActivityIndicator, Text, View } from 'react-native';
export default class FetchExample extends React.Component {
constructor() {
super();
this.state = {
posts: []
}
}
componentDidMount() {
let dataURL = "https://click9ja.com/wp-json/wp/v2/posts";
fetch(dataURL)
.then(response => response.json())
.then(response => {
this.setState({
posts: response
})
})
}
render() {
let posts = this.state.posts.map((post, index) => {
return
<View key={index}>
<Text>Title: {post.title.rendered}</Text>
</View>
});
return (
<View>
<Text>List Of Posts</Text>
<Text>{posts}</Text>
</View>
)
}
}
Any advice will be appreciated.