Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't find specific single user email query in Mongodb database?

API response show all user data in database to website UI

const [product, setProduct] = useState([]);
const [user] = useAuthState (auth)
useEffect(() => {
    const email = user.email;
    const url = `https://boiling-fjord-43680.herokuapp.com/productapi?email=${email}`;
    fetch(url)
        .then(res => res.json())
        .then(data => setProduct(data));
}, [user]);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

try to use params here , i have also faced the same problem and solved it in the following way:(note i have used id as identifier whereas u used email)

const { id } = useParams();

const [item, setItem] = useState({});

useEffect(() => {
const url = https://floating-atoll-94813.herokuapp.com/item/${id};
fetch(url)
.then((res) => res.json())
.then((data) => setItem(data));
}, []);

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading