gpt4 book ai didi

javascript - React Native Expo 请求失败,状态码为 404

转载 作者:行者123 更新时间:2023-11-30 20:24:22 25 4
gpt4 key购买 nike

我正在尝试在 iOS 设备上的 React Native Expo 应用程序中向我的服务器发出请求。

我的服务器在 heroku 上并且使用 HTTPS。

这里是请求代码

axios.post(`${SERVER_URL}/users`, {
data: {
phoneNumber: phoneNumber.value,
countryCode: '374',
firstName: firstName.value,
lastName: lastName.value
}
})
.catch(err => console.error('sign up err', err))
.then(res => {
console.log('res', res.data)
})
}

下面是显示的错误

注册错误错误:请求失败,状态码为 404

我也试过使用 fetch 但得到了同样的 404 错误。

这是我在手机上得到的

enter image description here

最佳答案

从错误消息来看,您的 URL 格式似乎不正确。您有一个额外的斜杠 (/)。

_response: {
status: 404,
message: "Not found"
},
_url: "https://join1.herokuapp.com//users"

如果 SERVER_URL 变量末尾有斜杠,请删除该斜杠或删除用户前面的斜杠。

示例

axios.post(`${SERVER_URL}users`, { /* some config */ })

关于javascript - React Native Expo 请求失败,状态码为 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51082633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com