How to make a GET request in JavaScript

Making GET requests is fundamental for fetching data from APIs, loading external resources, and retrieving server-side information. As the creator of CoreUI, a widely used open-source UI library, I’ve implemented countless GET requests for data fetching in dashboard components and dynamic content loading. From my expertise, the modern fetch() API is the best approach for making HTTP requests with its promise-based interface and built-in JSON parsing. This method is well-supported, clean, and provides excellent error handling capabilities.

Use fetch() to make GET requests and handle responses with promises.

fetch('https://api.example.com/users')
  .then(response => response.json())
  .then(data => console.log(data))

Here fetch() makes a GET request to the specified URL and returns a promise. The first .then() converts the response to JSON format, and the second .then() receives the parsed data. GET is the default HTTP method for fetch, so no additional configuration is needed for simple data retrieval.

Best Practice Note:

Always handle errors with .catch() and check response.ok before parsing. This is the same approach we use in CoreUI components for reliable data fetching and user feedback during loading states.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author