After querying data from my MongoDB database, I am faced with the challenge of sending a GET request from the front end to meet this specific query. In my backend code, I retrieve the data using the following:
const products = await Product.find({
'backCamera.sensor.megaPixels': { $gte: 8 }
})
I attempted to send a GET request in the frontend using the approach below, but unfortunately, it did not yield the expected results:
I've tried this way but didn't work
fetch('http://localhost:5000/api/v1/products?backCamera.sensor.megaPixels[gte]=8')
.then(response => response.json())
.then(data => console.log(data));
Furthermore, I also experimented with incorporating query params in the backend, however, I encountered issues that prevented its successful execution.