【发布时间】:2021-08-23 19:10:23
【问题描述】:
我正在我的 Mac 上的 android 模拟器上运行我的应用程序,并尝试访问部署在 firebase 上的服务端点。我收到 500 错误,什么也没说,当我尝试打印错误时,它显示 There was a problem sending log messages to your development environment [PrettyFormatPluginError: value.hasOwnProperty is not a function. (In 'value.hasOwnProperty('tag')', 'value.hasOwnProperty' is undefined)]。
当我尝试使用邮递员和相同的有效负载访问同一个端点时,我能够成功地做到这一点。
以下代码写在应用程序中
fetch('https://{app_url}.cloudfunctions.net/app/user', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: userPayload
})
.then(response => response.text())
.then(result => {
console.log('User in DB created');
console.log(result);
})
.catch(error => console.log('error', error));
有人可以帮我吗?
【问题讨论】:
-
只是猜测 userPayload 可能为空或缺少您的后端期望的标签信息,您可能正在测试。
-
您好@Atmas,我正在从我的应用程序传递相同的有效负载,并且不需要标签信息。但这无济于事。
-
你能粘贴你的用户负载吗?
-
“app_url”呢?您确定它指向正确的网址吗?
-
有效载荷:{“dob”:“09/09/1996”,“email”:“test1@gmail.com”,“nameOfTheUser”:“ABtest”,“phoneNumber”:“9898989898” ", "userId": "49178" }
标签: firebase react-native fetch