【发布时间】:2017-03-02 17:02:27
【问题描述】:
我正在用 react-native(和 native-base)构建一个应用程序。 我正在使用 ruby on rails (mysql2) 创建数据库。我有一个带有 cid 和 cname 的表类别。我正在使用以下代码从该表中获取所有数据。这将从类别表中获取所有数据。
fetchData() {
let lurl = 'http://192.168.43.92:3000/categories.json';
fetch(lurl)
.then((response) => response.json())
.then((responseJson) => { this.setState({ categories: responseJson}); })
.catch((error) => { console.error(error); });
}
如何获取特定字段,例如 cid=1 的字段(从 cid=1 的类别中选择 *);。
还有如何使用 fetch 函数插入到这个表中。
【问题讨论】:
标签: react-native fetch