I am a math tutor currently helping middle and high school students master common math concepts, and getting them prepared for the SAT and ACT tests.
I am also a computer programming enthusiast, especially interested in data analytics using Python, SQL and R.
I previously worked in international marketing and product development for Stanley Black & Decker, for more than 25 years.
👋 Contact me at mario@mariosanchez.org.
Web app to fetch stock info from an API and display it using React
Made with: React
Update: As of May 9, 2020, the API I was using to fecth the stock info has gone out of business so the values you will get in the Demo are all null. The functionality of the app, though, remains correct. I will update as soon as I find another free API.
To build a stock info app using React.
We wanted a simple form that let us input stock symbols. Upon submission, we wanted a page listing the names of those companies, hyperlinked to a specific company page where we could look at some financials.
Fig. 1: Input a few symbols and send the form:
Fig 2: List of companies whose symbols we submitted
Fig 3: Financials for each company
We used React to render our HTML pages. We used a third party API for the stock info. We used the fetch()
method to get the info from the API. We then used React routes and hooks to render the pages dynamically, using the parameters in the search query.
We used URLSearchParams(window.location.search)
to grab the query string parameter values.
We passed those values to our API endpoint using fetch()
and then parsed the response with the json()
method.
Once we received the info, we used React’s new useState
and useEffect
functions to update our components and state. To make sure that the React components didn’t render before the info from the API arrived, we used the async
and await
flags.
Both the list of company names and the individual stock pages are generated dynamically, using the parameters in the query string.
© 2025 Mario Sanchez Carrion