【发布时间】:2016-12-25 14:25:45
【问题描述】:
我正在我的组件中进行一个简单的 fetch 调用,看起来像这样
var x = fetch(SOME_URL, SOME_POST_DATA)
.then((response) => response.json())
.then((responseJSON) => {return responseJSON});
console.log(x);
调用成功执行,但控制台打印的是 promise 而不是数据。我在这里错过了什么?
【问题讨论】:
-
Promise 不会使任何东西同步,你无法获得价值。使用
x.then(console.log)
标签: javascript react-native fetch react-android