How To Make an API Call In HTML (Make simple HTTP/HTTPs request in JS tutorial)

preview_player
Показать описание
(We're free online community, meet other makers!)

#html #api #call #javascript #js #coding #webdev #webdevelopment #programming We don't really make API calls in HTML but in JavaScript. But people who don't yet know are searching for this. So here we are going to type JavaScript between script tags on an HTML page and make an http request to weather API. The actual API call is made using the built-in JavaScript function fetch()

00:00 How to make API call in HTML
00:10 Starting with a blank HTML file and script tags to enter javascript
00:38 Create async function to make our API call
00:55 Assign result from fetch function to a constant, and make that call await
01:34 Convert the returned object to JSON and resolve the promise with .then() method
02:17 Make the API Call
02:31 Extract temperature property from the returned JSON object
Рекомендации по теме
Комментарии
Автор

thank you for very detailed video! It's very helpfull!

softwaretestinglearninghub
Автор

The URL I want to make an API call from requires the API key to be in a header, how would I integrate a header into this?

cheetahbeeta
Автор

Replace
console.log('It's ${temp}F in London.')
with
= "It's " + temp + "F in London";
And you have a a working webpage without the need to peek in the console.

neumanngregor