written by: Menem Elkatan
--------- in: April 27, 2022

JavaScript GET Requests: A How-To



Want to make a GET request from JavaScript in a webpage, to display some data or information from an API? In the screenshot above, all that information, live, is being pulled into a webpage.

You can see the code from the screenshot in action here at javascriptpage. It can take up to few seconds to load, because it’s fetching the data from an API (also, it’s on a free tier, without authentication).

I didn’t hand-code any of that price information , remember –  it’s all coming from an API.

By writing GET requests in JavaScript into your code, you can also make that happen.

Let’s start with the API. To make a GET request, you have to request it from an API.

API stands for Application Programming Interface.



An API is an endpoint - a URL - you visit to get something in return.

In this case, we’re making a GET request, which the API answers with text.

Here’s we’re using an API called DomainsDB.info, to fetch information in response to a request.

As an example, look at the GET request below, which retrieves all webpages that have medium in their name.


You can see the API returns just by visiting it in your browser. Click the link; you’ll see text, as in this screenshot (pretty printed using an extension in my browser).


Made with by Menem Elkatan