Im trying to console log a certain field in my react app. I'm trying to log a certain columns from the table. The table itself looks like this:
I'm trying to console log the listingTitle column for a selected oid as we can see from the code.
Here is my code:
const [item, setItem]= useState([]);
const fetchItem= async ()=>{
const fetchItem= await fetch (`http://link to server/items?oid=${match.params.oid}`
);
const item= await fetchItem.json();
setItem(item.rows[0])
console.log(item.listingTitle)
The console log logs "undefined" and im not sure why it does that.
Thank you for your help in advance!
When i console.log(item) on its own this is what fetch returns:
When i tried the code below:
useEffect(() => {
console.log(item)
}, [item])
toast.configure()