Good afternoon.
I am querying a file of type Json, when I make the request it returns in a String format, such as to make it come in a JSON format to be manipulative.
reqListener() {
return new Promise((resolve, reject) => {
// function reqListener() {
// console.log(this.responseText);
// };
let oReq = new XMLHttpRequest();
oReq.onload = () => {
if (oReq.readyState == 4) {
if (oReq.status == 200) {
resolve(oReq.responseText);
}
} else {
reject("erro ao conectar");
}
};
oReq.open("get", "list.json", true);
oReq.send();
})
}
Json:
{
"cliente": [
{
"nome": "Rumble",
"peso": 50,
"altura": 1.40
},
{
"nome": "Ana",
"peso": 70,
"altura": 1.80
},
{
"nome": "Jose",
"peso": 90,
"altura": 1.30
},
{
"nome": "Jose",
"peso": 90,
"altura": 1.30
},
{
"nome": "Jose",
"peso": 90,
"altura": 1.30
}
]
}