R
Reactiflux

React and Fetch Api; Returning reacts index.html File instead of api endpoint?

React and Fetch Api; Returning reacts index.html File instead of api endpoint?

Xxboxman5551/26/2023
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))
Solution:
do you not have https:// on either of them?
Jump to solution
UUUnknown User1/26/2023
Message Not Public
Sign In & Join Server To View
Xxboxman5551/26/2023
this code is inside of a component
Gghardin1371/26/2023
is it exactly that code?
Xxboxman5551/26/2023
yeah its bringing back my index.html
Gghardin1371/26/2023
well you haven't given fetch() a url, so it's using the existing one or anything else for that matter
Xxboxman5551/26/2023
i have one, got rid of it for posting it
Gghardin1371/26/2023
that's why i asked if it was exactly that code what url is there?
Xxboxman5551/26/2023
open weather api and a time api
Gghardin1371/26/2023
can you post the actual url, you can remove any api keys or anything
Xxboxman5551/26/2023
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
Gghardin1371/26/2023
do you not have https:// on either of them?
Xxboxman5551/26/2023
no
Gghardin1371/26/2023
thats why you need that
UUUnknown User1/28/2023
7 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

React and Fetch Api; Returning reacts index.html File instead of api endpoint?

Join Server