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))
Solution:
do you not have
https://
on either of them?Unknown User•480d ago
Message Not Public
Sign In & Join Server To View
xboxman555•480d ago
this code is inside of a component
ghardin137•480d ago
is it exactly that code?
xboxman555•480d ago
yeah
its bringing back my index.html
ghardin137•480d ago
well you haven't given
fetch()
a url, so it's using the existing one
or anything else for that matterxboxman555•480d ago
i have one,
got rid of it for posting it
ghardin137•480d ago
that's why i asked if it was exactly that code
what url is there?
xboxman555•480d ago
open weather api and a time api
ghardin137•480d ago
can you post the actual url, you can remove any api keys or anything
xboxman555•480d ago
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
ghardin137•480d ago
do you not have
https://
on either of them?xboxman555•480d ago
no
ghardin137•480d ago
thats why
you need that
Unknown User•477d ago
Message Not Public
Sign In & Join Server To View
227KMembers
View on DiscordMore Posts
✅ – Cory – 19-42 Jan 25Why does `addEventListener` log twice if I manually pass `e` to the callback, but only logs once if ⛄Snowberb⛄ – 12-30 Jan 25How could I watch all API responses through the app? I need to know when any of the API calls return_mercury – 05-29 Jan 25could i create a middleware ( interceptor) that intercepts all ajax request the page does?VuNguyen – 05-09 Jan 25How this blur effect be done? (YouTube)If you use React, you should be using a React frameworkTweets from acdlite. Whatcha think?
https://twitter.com/acdlite/status/1617611126514266112
https://autoimports of react or next in vscodeI've got a nextjs project with framer motion.
Every time I want to import react hook I can’t just lxd – 14-14 Jan 23Unable to access state in redux toolkit app✅ – Adi – 11-00 Jan 23[How to secure API routes in Nextjs]_mercury – 22-34 Jan 21I have a situation
in some dynamic requests
the response is csv file
I could not download the ajax ✅ – dk.dv – 17-33 Jan 20Hi, beginner here, got an issue that probably has a simple solution but I'm not sure how to proceed: