// get my item
app.get("/product", async(req, res)=>{
const email = req.query.email;
const query = {email}
const cursor = productCollection.find(query)
const product = await cursor.toArray();
res.send(product)
})
Here is my backend code . that call email from my client side . and I do the query for specific item I get. then I use find method from mongodb.
const [user] = useAuthState(auth)
const [items, setItems] =useState([])
const email = user?.email;
useEffect(()=>{
const url = `http://localhost:5000/product?email=${email}`;
fetch(url)
.then(res=>res.json())
.then(data=>{
console.log(data);
setItems(data)})
},[email])
and here is the client-side code. In this code, I collect the current user which has an email name. I basically search with email.