我想知道如何在我的应用程序中查看我的fetch查询中的数据。
我有一个从react native获取的节点,我想显示响应。
节点部分;
app.get('/balance', function(req, res){
//calling the function
res.jsonp('0');
console.log("CRYPTO CALLED");
});
反应功能;
_getBalanceFromApiAsync() {
fetch('http://192.168.1.100:3000/ballance')
.then(response => response.json())
.then(responseJson => {
console.log(responseJson);
return responseJson;
})
.catch((error) => {
console.error(error);
});
}
我可以在节点控制台和反应控制台中看到结果。但不起作用的地方就在这里。
本地应用程序;
<Text style={styles.getStartedText}>Your Wallet Balance</Text>
<Text> {this._getBalanceFromApiAsync()}</Text>
</View>
函数正在执行,但我想显示返回的值,因为文本字段是空的
谢谢你