I want to print out the response of my fetch request in react native.
How would I do this to get the response inside a Text?
function Nft() {
fetch(
"https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"
);
return (
<View>
<Text style={style.header}>Bitcoin Price</Text>
</View>
);
}
export default Nft;
2
Answers
Please refer the following code
**In your component you can right in this way
Define state variable like following
then replace fetch code by following
In your component you can right in this way