0
Speaks beauty guys, I’m doing tests extracting data from a wp api using React I can extract all the data but the image was not successful, I started a short time with React
export default class App extends Component {
state={
data:[],
}
fetchData = async() =>{
const response = await
fetch('http://dominio.com.br/app/wp-json/wp/v2/posts');
const posts = await response.json();
this.setState({data:posts});
}
componentDidMount(){
this.fetchData();
}
render() {
return (
<View>
<FlatList
data={this.state.data}
renderItem={({item})=><Postagens data={item} />}
keyExtractor={(item, index)=> item.id}
/>
</View>
);
}
}
class Postagens extends Component {
render(){
return(
<View style={styles.posts}>
<Image source={{uri:'this.props.data.better_featured_image.media_details.sizes.thumbnail.source_url'}} style={styles.imagem} />
<Text>{this.props.data.title.rendered}</Text>
<Text>{this.props.data.excerpt.rendered}</Text>
</View>
);
}
}