Metanoia
Metanoia
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
ive been asking chatgpt for assistance but i fear it isn't a talented coder 😅
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
hi. i'm sorry to be bothering you again, i was just in need of some help with adding functionality because i feel like im not understanding react or node very well (my entire project is based on a course, and im doing it for school). would you mind helping me or providing examples on how to implement sorting and filtering my list of products?
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
how would i go about that
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
so you believe it is better i move all this to a separate page?
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
that is without creating an entirely new screen for it
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
No description
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
thank you! i appreciate your help greatly
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
i would've never thought of this lol
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
yay! it now toasts 'no results'
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
okay, it still doesn't improve
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
tysm
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
becuase even as this, toast still doesnt show :/
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
so, just to be clear, ive set it to
app.use("/", searchRoutes);
app.use("/", searchRoutes);
and the search routes to
router.get("/", async (req, res) => {
const { keyword } = req.query;

try {
// Query the database for products that match the keyword
const products = await Product.find({
name: { $regex: new RegExp(keyword, "i") },
});

res.json(products);
} catch (error) {
console.error("Error searching products:", error);
res.status(500).json({ message: "Internal server error" });
}
});
router.get("/", async (req, res) => {
const { keyword } = req.query;

try {
// Query the database for products that match the keyword
const products = await Product.find({
name: { $regex: new RegExp(keyword, "i") },
});

res.json(products);
} catch (error) {
console.error("Error searching products:", error);
res.status(500).json({ message: "Internal server error" });
}
});
. is this the correct approach?
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
so i should modify that line with the new url?
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
Atlas
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
so that means that the front is handling it okay i guess?
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
was it helpful?
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
I apologize for the delay. https://github.com/deahlt/shop
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
okay, ill share in a min
82 replies
KPCKevin Powell - Community
Created by Metanoia on 1/28/2024 in #back-end
MERN Stack - Search box returning empty array
i'll deploy my site on render in a second, if that helps
82 replies