await axios get code example
Example 1: async axios call
async getUserAsync(name) {
try{
let response = await axios({
method: 'get',
url: `https://api.github.com/users/${name}`,
json: true
});
return response;
} catch(err){
console.error(err);
}
}
Example 2: how to use axios get
const req = async () => {
const response = await axios.get('https://dog.ceo/api/breeds/list/all')
console.log(response)
}
req() // Calling this will make a get request and log the response.