I've a problem with React, I want to update a state variable with an object, but it doesn't update anything. Code:
async function getServers() {
console.log("ready")
const response = await fetch('http://localhost:3000/server/servers').then(res => res.json())
setServers(response);
console.log(response)
console.log("servers object updated: " + JSON.stringify(servers));
}
useEffect(() => {
getServers();
import('bootstrap/dist/js/bootstrap');
WebFont.load({
google: {
families: [ 'Karla:600', 'sans-serif' ]
}
});
}, []);
Someone can tell me why it doesn't update?
Thanks in advance and sorry for bad english!