Flutter Post:具有不同URL的多个API请求
当用户尝试登录时,我有一个未来:Flutter Post:具有不同URL的多个API请求,flutter,rest,dart,Flutter,Rest,Dart,当用户尝试登录时,我有一个未来: Future<String> login(String phone, String password) async { _firebaseMessaging.subscribeToTopic('all'); _firebaseMessaging.getToken().then((fmctoken) => print(fmctoken)); Response response = await _dio.post(log
Future<String> login(String phone, String password) async {
_firebaseMessaging.subscribeToTopic('all');
_firebaseMessaging.getToken().then((fmctoken) => print(fmctoken));
Response response = await _dio.post(loginUrl, data: {
"login": phone,
"password": password,
});
return response.data["objectId"];
}
未来登录(字符串电话、字符串密码)异步{
_firebaseMessaging.subscribeToTopic('all');
_然后((fmctoken)=>print(fmctoken));
响应=等待发布(逻辑,数据:{
“登录”:电话,
“密码”:密码,
});
返回响应。数据[“objectId”];
}
在未来,我还将获得fmc_设备_令牌,我希望将其上载到其他rest_api_url。问题是,我需要这样:返回response.data[“objectId”]代码>上载数据的objectId
如果调用了这个Future并接收到objectId,那么我如何使fmctoken_设备的值上传(post)到其他url上
谢谢你的帮助 在另一个函数中,您需要response.data[“objectId”]代码>以上载数据
您可以调用登录
函数,等待其响应,然后进行更新
Future<dynamic> myotherFunction(String phone, String password)async{
var response= await login(phone,password);
//heere you have your `objectId`
print(response);
}
Future myotherFunction(字符串电话、字符串密码)异步{
var响应=等待登录(电话、密码);
//你有你的目标吗`
打印(回复);
}