Use async/await
or promises within lifecycle hooks or methods:
async mounted() {
try {
const response = await axios.get('https://api.example.com/data');
this.data = response.data;
} catch (error) {
console.error('Error fetching data:', error);
}
}