APIs in JavaScript

JavaScript can interact with APIs (Application Programming Interfaces) to fetch data from external services.

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

async function getData() {
  const response = await fetch('https://api.example.com/data');
  const data = await response.json();
  console.log(data);
}