Skip to content

2. Usage

greatlygravitate edited this page Nov 7, 2021 · 1 revision

To use it, you use the function get and add a .then statement to get the promise. For example:

get("https://google.com").then(data => {
  console.log(data);
})

If you are accessing JSON and want to parse it, you use the json function:

get("https://jsonplaceholder.typicode.com/todos/1").then(data => {
  console.log(data.id); // getting undefined
  data = json(data);
  console.log(data.id); // getting 1
})

© Get-Page contributors. All rights reserved

Clone this wiki locally