firebase 本地模拟端:
initialize_app()
@https_fn.on_call( cors=options.CorsOptions(
cors_origins="*",
cors_methods=["get", "post", "options"],))
def validateEmail(req: https_fn.CallableRequest) -> Any :
return {"text":{"valid:":"true"}}
Android 应用程序端。
val func = Firebase.functions
private fun validateEmail(str:String): Task<String> {
val data = hashMapOf(
"email" to str
)
return func.getHttpsCallable("validateEmail").call(data)
.continueWith()
{ task ->
println("RAM_DBG" + task.result?.data.toString())
task.result?.data as String
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
func.useEmulator("localhost", 5001)
validateEmail("[email protected]")
.addOnCompleteListener { task ->
if (!task.isSuccessful)
{
val e = task.exception
if(e is FirebaseFunctionsException)
{
println("RAM_DBG:" + e.code.toString() + e.details.toString())
}
}
}
这总是给出 FirebaseFunctionsException 和 code = INTERNAL。怎么了? 两侧都有哪些仪器和记录可能? 当使用如下的curl运行时
curl -H "Content-Type:application/json" -d @book.json -X POST http://127.0.0.1:5001/<app>/us-central1/validateEmail
{"result":{"text":{"valid":"true"}}}
期望返回“valid:”:“true”
键“valid:”可能会因为冒号而导致问题。将其更改为“有效”