-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manage store api not working #2
Comments
how to correct manage store api |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const Store = require("../models/store");
// Add Store
const addStore = (req, res) => {
try {
console.log(req.body); // Log the request body
const { userId, name, category, address, city } = req.body;
} catch (err) {
console.error("Error adding store:", err); // Log the error
res.status(500).send(err);
}
};
// Get All Stores
const getAllStores = async (req, res) => {
try {
const { userID } = req.query;
console.log("UserID:", userID); // Log the userID
const findAllStores = await Store.find({ "userID": userID }).sort({ _id: -1 });
res.json(findAllStores);
} catch (err) {
console.error("Error fetching stores:", err); // Log the error
res.status(500).send(err);
}
};
module.exports = { addStore, getAllStores };
here on the console its showing UserID undefined
Data also not getting added to mongodb
The text was updated successfully, but these errors were encountered: