【发布时间】:2020-07-18 05:24:10
【问题描述】:
当我尝试从 Flutter 调用可调用函数时,我在使用 Firebase Cloud Functions 时遇到错误。
flutter: caught generic exception
flutter: PlatformException(functionsError, Firebase function failed with exception., {message: NOT FOUND, code: NOT_FOUND})
这是我尝试使用 cloud_functions 调用云函数的方法:^0.4.2+3
import 'package:cloud_functions/cloud_functions.dart';
_check(String id) async {
HttpsCallable callable = CloudFunctions.instance
.getHttpsCallable(functionName: 'checkUserFavorites');
try {
final HttpsCallableResult result = await callable.call(
<String, dynamic>{
'id': id,
},
);
print(result.data);
} on CloudFunctionsException catch (e) {
print('caught firebase functions exception');
print(e.code);
print(e.message);
print(e.details);
} catch (e) {
print('caught generic exception');
print(e);
}
}
【问题讨论】:
-
问题似乎与云功能本身有关。当它们在 region('europe-west1') 或 region('europe-west2') 中运行时,它们会因 PlatformException(3840, The data could not be read because it is not in the correct format., null) 或 PlatformException 而失败(functionsError,Firebase 函数因异常而失败。,{消息:未找到,代码:未找到})。不是所有地区都支持可调用函数吗?当不定义区域时,函数按预期运行,没有任何问题或错误。
标签: flutter google-cloud-functions