Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

65
Views
I can't get specific selected query items
// 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.

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs