0
buscarUsuario.onclick = function() {
            var usuario = document.getElementById("usuario").value;
            var resultado = buscaUsuario(usuario);
            console.log(resultado);
          }
const buscaUsuario = async(usuario) => {
          var http = new XMLHttpRequest();
          let url = 'http://192.168.1.144/status?usuario=' + usuario;
              http.onreadystatechange = () => {
                  if (http.readyState == 4 && http.status == 200) {
                      var data = http.responseText;
                  }else {
                    var data = "Error ao buscar, tente novamente";
                  }
                  return data;
              }
              await http.open("GET", url, true);
              await http.send();
        }
How do I get the console.log to return the result of the search functionUsuario, which would be the answer of the page that sends the argument? the result of the log console is:
Promise {status: "pending"}
I saw that it has something to do with . then or . catch but I never used it and I didn’t understand how to implement in the code.
I don’t know much about it, but it shouldn’t be
var resultado = await buscaUsuario(usuario);?– Jéf Bueno
That’s what Hiago said, I put it this way but returns Undefined, do not know the reason.
– Vitor Pereira