简体   繁体   中英

React - axios.post error 'Request failed with status code 404'

Facing error while submitting form in React using axios.post. Please help to resolve the issue. Code sample added in codesandbox linked below.


  const formSubmit = async (e) => {
    e.preventDefault();
    console.log(user);
    await axios.post(url, user);
    history.push("/");
  };

Error:

在此处输入图像描述

Code: Codesandbox link

From the wiki:

The 404 or Not Found error message is a HTTP standard response code indicating that the client was able to communicate with the server, but the server could not find what was requested. so, your code is OK, but server cannot find resource you are looking for. Double check if your url is correct.

You need to check if you're entering the correct url for the post request.

I have th same problem, but aftrer verifying the url the problem resists. It works with postman.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM