Essay
Essay
KPCKevin Powell - Community
Created by Essay on 7/30/2023 in #front-end
How to make API calls to different environments?
Hello everyone, I am developing a small website using vanilla HTML, CSS, JS. In my JS files a make a couple of api calls using the Fetch API, but I need to change the base path when I am running locally (from time to time I need to call a local instance of the backend), test or prod environment. I did not find a good way to handle this situation, is there anything I can do? Also, I'll need to put the whole thing in an Nginx container and serve it from docker, is there any way I can deploy the same image in every environment? Or am I tied to having an image for every environment for the sake of changing the base URL?
8 replies
KPCKevin Powell - Community
Created by Essay on 3/21/2023 in #front-end
How does this example from React documentation work?
Hello guys, I'm reading the new React documentation but I don't understand a little thing. In the step 5 in this page https://react.dev/learn/reacting-to-input-with-state the handleSubmit function updates the status state 2 times (one at the top level and one inside try/catch). How is that possible? Shouldn't state be updated with just the last value? I tried to add a new counter state and increment it by 1 every time that setStatus is called, and it actually gets incremented only by one per submit, as I expected... so why is setStatus different?
4 replies