React and Fetch Api; Returning reacts index.html File instead of api endpoint?
My Fetch Api with react is returning index.html instead of its data is there something with react I need to change?
```
fetch()
.then((response) => response.json())
.then((data) => console.log(data))
fetch() .then((response) => response.text()) .then((data) => console.log(data))
fetch() .then((response) => response.text()) .then((data) => console.log(data))
14 Replies
this code is inside of a component
is it exactly that code?
yeah
its bringing back my index.html
well you haven't given
fetch()
a url, so it's using the existing one
or anything else for that matteri have one,
got rid of it for posting it
that's why i asked if it was exactly that code
what url is there?
open weather api and a time api
can you post the actual url, you can remove any api keys or anything
www.timeapi.io/api/Time/current/zone?timeZone=America/New_York
api.openweathermap.org/data/2.5/weather?lat=32.779167&lon=-96.808891&appid=...
it has other things such as export default function
stuff you would find in a component too
i found something with proxy in package.json, maybe that got something to do with it
@ghardin137 u there?
Solution
do you not have
https://
on either of them?no
thats why
you need that
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View