'How can I filter the data using user Email

As a result, not all of my data is available from the All Items component. I want users to login to my website and add items only by filtering out the items that have been added by their email. And when the user going All Items Complete, all the data will be together. But my code is not working so I want a solution.

This is my client site reactjs code.

useEffect(() =>{
    
    
    const getMyitems = async() =>{
        const email = user?.email;

        const url =`http://localhost:5000/service?email=${email}`;
        const {data} = await axios.get(url, {
            headers:{
                authorization: `Bearer ${localStorage.getItem('accessToken')}`
            }
        });
        setMyitems(data);
    }
    getMyitems();

},[user])
return (
    <div>
        <h1> your items : {myitems.length}</h1>
    </div>
);

This is server site Api code

    app.get('/service', verifyJwt, async (req, res) => {

        const authHeader = req.headers.authorization;
        console.log(authHeader);


        const email = req.query.email;
        const query = { email: email };





        //const query = {};
        const cursor = serviceCollection.find(query);
        const service = await cursor.toArray();
        res.send(service);

    });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source