Search result via web service

Asked

Viewed 34 times

-1

I am building a search application (input) and it should bring the result of a webservice.

Example:

xhttp.open("POST", "https://www.site.br/api/v1/busca/termo/_pesquisa", true);
xhttp.setRequestHeader("Content-type", "application/json");
var data = JSON.stringify({"order":"relevancia","pagina":1,"q":"*"});
xhttp.send(data);

The return of this code brings the pure JSON of the web service and I would like to organize the data according to my HTML, with title, name and description (coming, of course, from the webservice).

Is there a practical example I can give? Thank you, from now on.

1 answer

0


You can take the pure Json and perform the "parse"

let jsonData = jsonRetorno.parse();

And then you can use the Json object:

   console.log(jsonData.titulo);
   console.log(jsonData.nome);
   console.log(jsonData.descricao);
  • 1

    That was very useful, I’ll use it from now on.

Browser other questions tagged

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