swift - Swift Firebase 函数错误:NSCocoaErrorDomain
问题描述
当我尝试从 Swift 运行 Firebase 函数时,我收到一条错误消息:
错误域 = NSCocoaErrorDomain 代码 = 3840 “JSON 文本没有以数组或对象开头,并且允许未设置片段的选项。” UserInfo={NSDebugDescription=JSON 文本没有以数组或对象开头,并且允许未设置片段的选项。}
这是 Firebase 功能:
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!")
})
这是我的 Swift 代码:
Functions.functions().httpsCallable("helloWorld").call { (result, error) in
if error == nil {
print("Success: \(result?.data)")
} else {
print(error.debugDescription)
}
}
解决方案
如果您没有在客户端指定正确的区域,您可能会看到此错误。例如:
lazy var functions = Functions.functions(region: "europe-west1")
推荐阅读
- influxdb - 如何拆分标签键和标签值
- c - 函数调用中指向 const 的指针
- authentication - ecryptfs-migrate-home 与域用户的主目录
- mysql - current_time() 的 MySQL 排序规则
- replace - 如何在ansible中替换某行之后的所有字符串?
- c# - 如何以线程安全的方式为每个 HTTP 请求维护一个对象?
- javascript - puppeteer 等效于 cypress contains() 方法
- javascript - IOS 应用程序在使用 JavaScript 命中时不重定向
- linux - 如何在设备树中设置 GPIO 引脚输出值
- linux - 在shell中处理带有空格的文件名