The code below pulls from a JSON object, however there's one major problem with it:
It's seeing 10 posts out of 98. I should see all 98 shouldn't I ? Since I'm using a flatlist it should pull all the available posts, but it stops at 10. However, if I console.log, I see about 30 posts, but still not all 98.
render() {
return (
<View style={styles.theContainer}>
<FlatList
data={this.state.data}
keyExtractor={(x,i)=>i}
renderItem={({item}) => {
return (
<View>
<HTMLView
value={item.title.rendered}
styles={styles.topicTitle}
/>
<HTMLView
value={item.excerpt.rendered}
/>
</View>
)}
}
/>
</View>
);
}
}
You need to override some properties in your flatlist. As a start, set the initialNumToRender property equal to the initial number of records you want to show.
Also, the API requires you to specify how many records you want like this:
/wp/v2/posts?per_page=100
See the docs here!
https://developer.wordpress.org/rest-api/using-the-rest-api/pagination/
From the docs:
"The API endpoints default to providing a limited number of items per request, the same way that a WordPress site will default to 10 posts per page in archive views."