Encountering 404 Error When Posting Registration Data to Server Endpoint in React Application

21 views Asked by At

POST http://localhost:3000/api/v1/user/register 404 (Not Found)

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);
    }
};
1

There are 1 answers

0
ishaan On

1.) Make sure your endpoint is configure(there might be some typos etc etc.) 2.) instead of axios, use fetch and see whether it works or not 3.) setup cors correctly