I have the following configured in the front end for react js
const [allowedUsers, setallowedUsers] = useState([]);
myService.getusers()
.then(function (result) {
if (result.allowedaccess) {
setallowedUsers(result.allowedaccess);
}
});
The problem is that if i debug then i can see that result.allowedaccess is populated , with the array [‘bob’, ‘mary’, ‘chris’] but if i console.log “allowedUsers” , the variable up top in the const , it is empty it should be an array like the following
['bob', 'mary', 'chris']
How can i set the variable ?