#Back-end with React

16 messages · Page 1 of 1 (latest)

soft cedar
#

Hey guys,
Currently I am using React with Vite to make a website, that shows information from the api. However because of the CORS policy error, I need to move my api requests from react to some kind of server. What would you recommend using with react for a back-end server side ? I tried to research and it seems that it is possible for example to use like Python flask, nodejs, nestjs. What would you recommend for me to do, as I am a bit lost here 😄 . Thanks. I'm a bit bettter with python than with javascript

soft cedar
#

ok just decided to do it both ways and see what i like better 😄

solar lynx
#

I would recommend node because it is pretty much javascript but if you are better with python then go ahead and use it :). Have fun!

winged adder
#

I agree with Hello above -- use what you're comfortable with as if will help if errors occur and you need to debug stuff. ✨✨

mighty notch
#

@soft cedar Just out of curiosity, which API are you trying to fetch data from and how are you trying to do it? If you're just fetching data from a third-party API you shouldn't need to go through a dedicated server.

soft cedar
#

so far like this:

      fetch(`https://euw1.api.riotgames.com/lol/summoner/v4/summoners/by-name/${playerNamesArray[i]}?api_key=${apiKey}`)
        
        .then(res => res.json())
        .then(data => setPlayerInfo((prevState) => [...prevState, data]))
    }
  }, [])```
mighty notch
soft cedar
mighty notch
#

So if you try just a single player the fetch request works fine?

#

When the error happens, what error code are you getting from the request? You can see this in the browser web tools "network" panel.

#

If fetching a single player works, but fetching multiple players fails, chances are you are getting rate limited on the API (this should result in a 429 error code) - Using a backend server for the fetch requests isn't going to magically by-pass the rate limit.

soft cedar
#

yep im getting 429, so do u know what are the options ? delaying the requests a bit or any other way ?:D

#

RATE LIMITS
20 requests every 1 seconds(s)
100 requests every 2 minutes(s)

soft cedar
#

@mighty notch ok with a delay it works, thanks for the info

mighty notch