Web APIs

 Web APIs


JavaScript has access to various Web APIs that provide functionality for interacting with web browser features and APIs, such as DOM manipulation, AJAX requests, and more.


// Fetch API for making HTTP requests

fetch('https://api.example.com/data')

  .then(response => response.json())

  .then(data => console.log(data))

  .catch(error => console.error(error));


// DOM manipulation using Document API

const element = document.querySelector('#myElement');

element.textContent = 'Hello, World!';

In the above example, the fetch function is used to make an HTTP request to an API endpoint and retrieve data. The querySelector method from the Document API is used to select an element in the DOM and update its content.

No comments:

Post a Comment

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...