在React应用程序中将注册数据发布到服务器端点时遇到404错误

问题描述 投票:0回答:1

POST http://localhost:3000/api/v1/user/register 404(未找到)

const handleSubmit = async (values) => {
    try {
        const res = await axios.post("/api/v1/user/register", values);
        if (res.data.success) {
            message.success("Registered Successfully!");
            navigate("/login");
        } else {
            message.error(res.data.message);
        }
    } catch (error) {
        console.log(error);
        message.error("Registration failed: " + error.message);
    }
};
node.js axios http-status-code-404 registration
1个回答
0
投票

1.) 确保您的端点已配置(可能存在一些拼写错误等) 2.)代替axios,使用fetch并看看它是否有效 3.) 正确设置cors

© www.soinside.com 2019 - 2024. All rights reserved.