Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

async function fetchJson

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)); 
Comment

async fetch api call

async function getUserAsync(name) {
  try{
    let response = await fetch(`https://api.github.com/users/${name}`);
    return await response.json();
  }catch(err){
    console.error(err);
    // Handle errors here
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript give class to element 
Javascript :: Get child node index 
Javascript :: document.queryselector vs document.getelementbyid 
Javascript :: js remove all objects from array where value 
Javascript :: moment js difference between start and end in hours 
Javascript :: set focus on input field javascript 
Javascript :: javascript json string 
Javascript :: how to use ctrl c and ctrl v using vim vscode extension 
Javascript :: copy object javascript 
Javascript :: How to show confirm message before delete using jquery 
Javascript :: get value of checked radio button jquery 
Javascript :: give div event listener functional component 
Javascript :: angular delete from array by name 
Javascript :: injected stylesheet remove 
Javascript :: material ui datepicker remove error 
Javascript :: axios upload progress react 
Javascript :: A form label must be associated with a control react 
Javascript :: format number javascript with comma 
Javascript :: js window redirect 
Javascript :: javascript redirect to another url example 
Javascript :: getelementsbyname 
Javascript :: react-native resource android:attr/lStar not found in Android 
Javascript :: js get file content from url 
Javascript :: get browser timezone 
Javascript :: discord js setinterval 
Javascript :: show hide boxes using radio button selection jquery 
Javascript :: sum two objects javascript 
Javascript :: js get anchor 
Javascript :: run react app in react 18 
Javascript :: jquery checkbox checked or not 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =