Here is a JSON array that I am working with:
{
"data": [
{
"id": 6,
"pnome": "dasda",
"unome": "dad",
"avatar": 1,
"email": "d",
"pass": "password",
"ponto": 0
},
{
"id": 3,
"pnome": "Enguias",
"unome": "Enguias outra vez",
"avatar": 10,
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4c29222b39252d3f0c29222b39252d3f6229222b39252d3f">[email protected]</a>",
"pass": "enguias",
"ponto": 0
},
{
"id": 2,
"pnome": "André",
"unome": "Marques",
"avatar": 1,
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4627212a2b273437332306212b272f2a6825292b">[email protected]</a>",
"pass": "yet1",
"ponto": 0
}
]
}
I then use Axios to put the JSON data into an array in my code:
axios.get(my_url_api)
.then((res)=>{
const txt = JSON.stringify(res.data.data);
const users = JSON.parse(txt)
})
My goal now is to extract specific attributes like email and pass from the users array. This is how I want it to be displayed:
{
"data": [
{
"email": "d",
"pass": "password"
},
{
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfdad1d8cad6deccffdad1d8cad6decc91dad1d8cad6decc">[email protected]</a>",
"pass": "enguias"
},
{
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f697919a9b9784878393b6919b979f9ad895999b">[email protected]</a>",
"pass": "yet1"
}
]
}