Im trying to get a product by its code id, but the result its empty array. My controller:
export const getProductByPLU = async (req, res) => {
const searchPLU = req.query;
try {
const product = await Product.find({ Code: { $eq: searchPLU } });
res.json({ data: product });
} catch (error) {
res.status(404).json({ message: error.message });
}
};
if i try to get this http://localhost:5000/products/search?3036 result is
> {
"data": []
}
I get all the products, just cant get that one specific. Simple Product:
{
"_id": "618a42e4801d324e3d84c16c",
"ProductId": "868",
"Name": "Aus Wagyu Flat WX5+",`enter code here`
"Barcode": 2000000001630,
"Code": 163,
}
/products/search?code=163,const searchPLU = +req.query.code;