I want to update state based on the response of fetch() function but i am unable to get the value instead getting Promise {}.If i console.log() the value is correct there.
state.product = fetch("https://fakestoreapi.com/products/2")
.then((res) => res.json()
.then((json) => {
console.log(json); // Correct value
return json;
})
);
console.log(state.product); // Promise {<pending>}