Fetch() vs axios.get

I would be deeply indebted to anyone who can explain why axios.get works but fetch() doesn’t here:

This returns data successfully

 const handleClick2 = async () => {
    const returned = await axios.get("https://randomuser.me/api")

    const formatted = JSON.stringify(returned)

    console.log("my fetched data", formatted)
  }


/* returned data = {"data":{"results":[{"gender":"male","name":{"title":"Mr","first":"Leão","last":"Barbosa"},"location":{"street":{"number":1693,"name":"Rua Santos Dumont "}, */

This returns an empty object. I can’t figure out why.

 const handleClick2 = async () => {
    const returned = await fetch("https://randomuser.me/api")

    const formatted = JSON.stringify(returned)

    console.log("my fetched data", formatted)
  }

// returned data = { }

This returns an object of “type:cors” with no data

 const handleClick2 = async () => {
    const returned = await fetch("https://randomuser.me/api")
    console.log(returned)
  }

/* returned data = Response {type: "cors", url: "https://randomuser.me/api", redirected: false, status: 200, ok: true, …}  */

I want to use fetch to return the same data I am able to return with axios.get.

Thank you

You need to call the json method available on the returned response.

const handleClick2 = async () => {
  const returned = await fetch("https://randomuser.me/api");
  const formatted = await returned.json();
  console.log("my fetched data", formatted);
}