I am trying to fetch this file but for some reason it keeps getting caught in an error
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then((response) => {
if (response.ok) {
return response.data() ;
}
throw new Error('Something went wrong');
})
.then( data => {
console.log("DATA: ", data);
return data;
})
.catch((error) => {
console.log("Could not fetch the url")
});
on my browser console I see this error
GET https://reqres.in/api/users?page=2 net::ERR_FAILED
fetchFunc @ VM179:17
(anonymous) @ VM179:10
main @ VM179:31
(anonymous) @ VM179:37
VM179:26 TypeError: Failed to fetch
at fetchFunc (<anonymous>:17:5)
at <anonymous>:10:27
at main (<anonymous>:31:11)
at <anonymous>:37:1
The url is correct Im not sure what Im doing wrong here