Advertisement

GET Request

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data));

POST Request

fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(data)
})

With Async/Await

const response = await fetch(url);
const data = await response.json();
Advertisement
Last updated: January 2026
Advertisement