Hi,
Im trying to assign to a variable of type json a response that comes from a fetch API array in a javascript expression.
Right now my javascript code looks like this:
if($data.usuarios && $data.usuarios.length){ // generate an array of url const urlUsuarios = $data.usuarios.map(usr => `../API/identity/user/${usr.user_id}`); // create an array of fetch const fetchPromises = urlUsuarios.map(url => fetch(url).then(resp => resp.json())); // execute all request Promise.all(fetchPromises).then(resps => { console.log(resps); // this print the array of users $data.posiblesUsuariosVar = resps; // this is assigment is not working }); }
Aother question that I have is if its posible to use async await syntax inside of a javascript expression
Thanks,