Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
    }
  }
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #How #fetch #data #api #async #await
ADD COMMENT
Topic
Name
7+6 =