Pass data from front to back, use dynamically for API call, pass response back to front

I realize this is complicated, and while I can clearly define the problem, it is essentially more than one. I just feel like if I can put this in one place, it may be better than writing many questions, as I’ve been working on this problem for some time now, and simply can’t entirely wrap my head around it all.

Tech:
It’s a React app created with Vite. I am using Node, express, and cors, along with dotenv for the API key. I have a client folder for the frontend code, and server folder for the backend. I have an App.jsx mainly for the frontend, and mostly a server.js for the back.

Background:
In essence, I am collecting user input from several form fields on the front end, which then need to be used as part of the external API request. So I need to save these values as variables to be used on the backend. Then on the backend, they will be inserted into the URL for the external API request. The response of the API request will contain a lot of data I don’t need, but there is one value (already identified) I will need to pass to the frontend to display on the page.

I am lost… The backend works just fine (server connects, can make external API request using sample data i.e. not the user input, but valid values I’ve inserted to be sure it can work, gets response just fine, and will console.log the single value I am trying to get, which I’ve saved in a variable).
Frontend looks okay, I have the three inputs that can be entered, it submits okay and gets stored, but then what?

My basic understanding is I need to route the data from the front to an api on the back (I’m using “/api”), and then pull it from there, but that’s where this starts breaking down for me. I need to get those values individually on the backend to then use dynamically for the external API request. And once I have the request response, how do I use that variable storing the data on the front end again?

If anyone can walk me through this, it would really help. I’ve been back and forth on this for weeks already, and feel like I just need a little more hand-holding at this point.

Thank you!!!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.