Get data from an API in React

In this article, I’ll show how to make a request to an API to get data and then display it in a React component. This can be broken down into three steps: Here’s a working code example of how to do this: Note: Install the axios package with ‘npm install axios’. If you prefer to … Read more

Hello World with React

I’m going to show you how to create a Hello World web app with React. Note: I’m using React 18, which is the latest version at the time of this writing. 1 – Install VS Code VS Code is a really good IDE for developing React apps. So first things first, go download and install … Read more

JavaScript – Post form data to a web API asynchronously

You can post form data asynchronously by using fetch() + FormData, like this: FormData parses the form element into an array of key/value pairs for you. This results in sending the following request: When you set the request body to a FormData object, it sets the content-type to multipart/form-data. You can post the data in … Read more

JavaScript – Send requests with fetch()

The simplest way to send requests in JS is to use the fetch() API. Here’s an example that gets a stock quote from a web API and displays the results: You can wire this up to a button click (and have a div for displaying the results): Note: fetch() is supported in all major browsers … Read more