HarmonyOS 鸿蒙Next最新版云函数调用失败
HarmonyOS 鸿蒙Next最新版云函数调用失败
Build info:emulator 5.0.0.31(SP37DEVC00E31R4P11log)
Fingerprint:79108adcb1d8b02f6c1f4bcde13491c3d3192613de0c3b67b2c8863c1703369e
Module name:com.example.fanCloud
Version:1.0.0
VersionCode:1000000
PreInstalled:No
Foreground:Yes
Pid:11370
Uid:20020036
Reason:TypeError
Error name:TypeError
Error message:Cannot read property call of undefined
Stacktrace:
at callIdGenerator (entry/src/main/ets/pages/CloudFunction.ets:59:5)
at anonymous (entry/src/main/ets/pages/CloudFunction.ets:39:9)
调用云函数官方的案例,在模拟器上调用失败
private callIdGenerator() {
cloudFunction.call({ name: ‘id-generator’ }).then((res: cloudFunction.FunctionResult) => {
this.globalId = (res.result as IdGeneratorResponse).uuid;
}).catch((err: BusinessError) => {
hilog.error(0x0000, ‘CloudFunction’, ‘call id-generator exception, ErrCode: %{public}d ErrMessage: %{public}s’,
err.code, err.message);
});
}
HarmonyOS 鸿蒙Next云函数调用失败可能由多种原因造成,如API版本不兼容、云函数配置错误或设备环境问题。请检查您的项目API级别是否与云函数服务兼容,并确保agconnect-services.json文件已正确配置。同时,云函数需在真机上运行以验证其正确性,模拟器可能无法完全模拟所有功能。如果问题依旧无法解决,请检查云函数日志获取更详细的错误信息。如果问题依旧没法解决请加我微信,我的微信是itying888。