Answer the question
In order to leave comments, you need to log in
Why does axios with async return a promise object?
async getTickets(slot_id) {
let tickets;
await axios.get('/api/tickets/' + slot_id)
.then(({data}) => {
tickets = data.data;
});
return tickets;
}
Answer the question
In order to leave comments, you need to log in
What do you expect with this code?
This is how it should be (roughly):
async getTickets(slot_id) {
try {
const { data } = await axios.get('/api/tickets/' + slot_id)
return data
} catch (e) {
throw new Error(e)
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question