Answers for "await fetch(new Request("

12

fetch await

async function getUserAsync(name) 
{
  let response = await fetch(`https://api.github.com/users/${name}`);
  let data = await response.json()
  return data;
}

getUserAsync('yourUsernameHere')
  .then(data => console.log(data));
Posted by: Guest on February-16-2020
0

How to fetch data from an api async and await

async function fetchData() {
    try {
      const result = await axios.get("https://randomuser.me/api/")
      console.log(result.data));
    } catch (error) {
      console.error(error);
    }
  }
Posted by: Guest on June-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language