How to get a response from an asynchronous call in JS?

Asked

Viewed 16 times

0

Hi! I’m doing a query in a database. I need to display this query as soon as possible, and I am not knowing 'encapsulate' it with the await or whatever.

The function is as follows:

const confereInicial = async (idAluno, idDisciplina) => {
  return await Axios.post("http://localhost:3001/api/check", {
    idAluno: idAluno,
    idDisciplina: idDisciplina
  }).data;
}

console.log (confereInicial(1,1));

How do I print this return as soon as possible? It shows 'Undefined'. I’ve seen about it on forums here stack overflow, but can’t apply in my case at all.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.