【发布时间】:2018-01-11 11:34:52
【问题描述】:
我开发了一个 API(node js、express 和 firebase)来在我的原生应用程序中使用它来反应我的 API 的结构: API:允许您在调用允许修改我的数据库 firebase 中的字段的函数后选择遵守特定条件的用户数:当我在浏览器上测试时,API 运行良好。
这是我的 API 的结构:
router.get ('/: senderID /: numberOfShare /: drop', function (req, res, next) {
// Code that allows users to be selected from the database FOREACH {
// call to a function (function2) which allows to modify the data of users in the BDD
}
// define the function2 here { modify user data in the database
}
}
我的问题是:如何从我的 react-native 应用程序中正确利用我的 API?
我做了一个测试,但没有工作。
测试:
shareDrop (drop, parent) {
fetch ('192.168.1.4:3000/users/senderID/numberOfShare/drop',
{ method: 'GET',
headers: {
Accept: 'application / json',
'Content-Type': 'application / json',
}
params: JSON.stringify
({
senderID: this.state.uid,
numberOfShare: 'parent.state.numberOfShare',
drop: drop
}),
});
}
【问题讨论】:
标签: node.js firebase express react-native