小编Iro*_*ugh的帖子

从 Android 中调用 Firebase Cloud Function 接收数据

我正在尝试调用我编写的 firebase 云函数。

我已经使用 Postman 测试了该功能来模拟 HTTP 请求。这是我在 Postman 中调用我的函数时的 JSON 结果:

{
 "groups": [
    {
        "isPublic": true,
        "members": [
            true
        ],
        "numberOfMembers": 1,
        "groupId": "-LAOPAzMGzOd9qULPxue"
    },
    {
        "isPublic": true,
        "members": [
            true
        ],
        "numberOfMembers": 1,
        "groupId": "-LAOP7ISDI2JPzAgTYGi"
    }
 ]
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试执行相同的操作并在我的 android 应用程序中检索此 JSON 列表。我正在关注 Firebase 网站上的示例:https ://firebase.google.com/docs/functions/callable

这是 Firebase 关于如何检索数据的示例:

return mFunctions
        .getHttpsCallable("addMessage")
        .call(data)
        .continueWith(new Continuation<HttpsCallableResult, String>() {
            @Override
            public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
                String result = (String) task.getResult().getData();
                return result;
            }
        });
Run Code Online (Sandbox Code Playgroud)

目前尚不清楚如何从我的云功能中获取结果并将其用于我的 …

java android firebase

5
推荐指数
1
解决办法
3656
查看次数

如何在Spring RequestBody中定义参数不为空?

我希望能够在Spring中将某些变量定义为非空@RequestBody。这样,Spring 的控制器将拒绝其主体不具有我定义为关键的某些变量的任何请求。我已经尝试过下面的代码,但它不起作用:

控制器:

@PutMapping("/")
ResponseEntity updateOptions(
   @RequestBody RequestDto requestDto
);
Run Code Online (Sandbox Code Playgroud)

RequestDto,我希望第一个参数始终被填充

import javax.validation.constraints.NotNull;

public class RequestDto {
   @NotNull
   String id;

   String message;
}
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

3
推荐指数
1
解决办法
5403
查看次数

标签 统计

java ×2

android ×1

firebase ×1

spring ×1

spring-boot ×1