api - 在 react-native 上使用令牌访问(发送令牌作为参数)获取 api
问题描述
我有这个链接:
https://link.com/link/ (API)
my token to acces web api is : xxxx
and parameter are idUser = 1, idCommande = 1
Methode : POST
我如何使用这个令牌 xxxx 从 api 获取数据?
解决方案
您可以使用 json.stringify 方法来传递令牌。
fetch('YOUR_URL', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
idUser : 1,
idCommande : 1,
})
})
推荐阅读
- javascript - 如何在画布上添加形状?
- ios - Xcode 10.1 - 模拟器崩溃尝试在横向 iPhone 8 Plus、iPhone XR 和 iPhone XS Max 中呈现 SKStoreProductViewController
- javascript - 当一个字符串以另一个字符串结尾时的字符串操作
- c - C中的空结构
- hadoop - 大数据堆栈不那么开放,导致安全需要 Ranger 和 Sentry
- r - 在R中将json转换为数据框
- google-play-services - RealTime Multiplayer:表示通过邀请启动
- python - 通过 python 库调用函数 AudioConfig.FromWavFileInput 时出现问题
- c++ - 带增强绑定的异步接受
- python - 动态编程 - 4 键键盘