-1

I'm trying to retrieve an object from an API with axios, but I get the following error:

Uncaught (in promise) Error: Request failed with status code 404

Pasting the same url in the browser gives me the correct view of the object, I don't know where the error is.

Code:

useEffect(() => {
    axios
      .get("www.themealdb.com/api/json/v1/1/random.php")
      .then((res) => console.log(res));
  });
juzello
  • 231
  • 3
  • 16

1 Answers1

0

I think you pass the invaild url to axios

//www.domain.com/page

the scheme may be not the same for the two requests and the request headers are not the same

you should check the two requests.

most times, http and https do not response the same thing

Bulog
  • 79
  • 2