【发布时间】:2022-01-16 13:08:44
【问题描述】:
从我的 MongoDB 数据库中,我正在查询数据。为此,在我的后端,我通过这个来获取数据,
const products = await Product.find({
'backCamera.sensor.megaPixels': { $gte: 8 }
})
如何从前端发送 GET 请求来满足这个查询?
我试过这种方法,但没有用
fetch('http://localhost:5000/api/v1/products?backCamera.sensor.megaPixels[gte]=8')
.then(response => response.json())
.then(data => console.log(data));
然后尝试在后端使用查询参数但没有成功。
【问题讨论】:
-
12 是干什么用的?你能在后台显示控制台记录请求参数的代码吗?
-
对不起,现在编辑..你可以重新检查
标签: javascript database mongodb rest mongoose