From the course: Introduction to Web APIs

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Make a request to the API

Make a request to the API - REST Tutorial

From the course: Introduction to Web APIs

Make a request to the API

- [Instructor] I've created a simple HTML page, just to have something so we can start working with the API. We're going to be working solely in JavaScript, so for the most part, you can ignore the HTML. All the code to follow along has been provided for you in the exercise files. The first thing we're going to need to do is make our request. We have a blank script.js file. To start a request to the H+ Sports API, we're going to write the Fetch method. So we'll write fetch and then open and closed parenthesis. Inside the parenthesis, we need to add the URL for the H+ Sports API. We can get that from the documentation. Here's the base URL, let's copy that, and then we'll paste it back into our code. The URL needs to go inside of quotation marks, so we're at opening and closing quotation marks. Now that we've connected to the API, and requested a response, we need to convert that response to JSON. So we'll create a Then…

Contents