So the login fetch it self works and the backend gives me a succes and my json file with the autherized status and the id i need for later on in the react app the problem now is if i console log the id and autherized var on the first login its not changing its variables instead it console logs me the default setting with 0 and false
let [autherized,setAutherized] = useState(false);
let [id,setId] = useState("0");
let [username,setUsername] = useState("");
let[password,setPassword] = useState("");
async function submitLogin(){
let data={
username:username,
password:password
}
const result = await fetch("http://localhost:5000/login",
{
method:"POST",
headers:
{
"Content-Type": "application/json",
},
body:JSON.stringify(data),
}).then((response)=>{
return response.json();
}).then((data)=>{
setId(data.id);
setAutherized(data.autherized);
console.log(id);
console.log(autherized);
});
}
i expected the react app in the fetch request to change the states of the id and autherized status on the first time i click on login