HomeToolsAbout a20k

Fetch

What is it

fetch() is used to accesses resources across the network

Accepts two parameters:

  • resource accepts URL string or Request object
  • options accepts object with attributes like method, headers, body
const response = await fetch(resource[, options]);

Return Value

fetch() starts a request and returns a Promise

  • If the request fails due to network problems, the Promise is rejected
  • when the request is complete, the Promise is resolved with the Response object
© VincentVanKoh