Basically I am trying to find a way how the fetch data works. I have created a method that returns a simple list and the response of the body is as follow:
[
{
"Name": "ApooBG",
"Password": "e062f192A",
"Email": "idk@abv.bg"
},
{
"Name": "VenszBG",
"Password": "12645",
"Email": "idkk2@abv.bg"
},
{
"Name": "PetarGH",
"Password": "1245",
"Email": "idkk3@abv.bg"
}
]
then I have in react a button that calls a method, where it should get this list.
<div> <button onClick={Testing}>Edit Info</button></div>
const Testing = () => {
fetch("https://localhost:7101/GetUsers")
.then((response) => response.json())
.then((data) => {
console.log(data);
})
};
When I try to click on the button I need to get the users in the console.log but instead I get:
Could you tell me what I am doing wrong as I really don't get the idea. The URL should be okay as this is what the request URL is. Therefore, the problem should be somewhere else.