client side code:From here I am trying to send request to the server
const MyItems = () => {
const [user] = useAuthState(auth);
const [myItems, setMyItems] = useState([]);
useEffect(() => {
const email = user.email;
console.log(email);
const url = `http://localhost:5000/products?email=${email}`;
fetch(url)
.then(res => res.json())
.then(data => {
console.log(data);
setMyItems(data);
})
}, [user]);
server side code:from here i am trying to get response
app.get('/products', async (req, res) => {
const email = req.query.email;
console.log(email);
const items= { email: email };
const cursor = productCollection.find(items);
const result = await cursor.toArray();
res.send(result)
})