Skip to content
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

Uploaded food items reference non-existent request data #27

Open
danny1461 opened this issue Nov 26, 2020 · 0 comments
Open

Uploaded food items reference non-existent request data #27

danny1461 opened this issue Nov 26, 2020 · 0 comments

Comments

@danny1461
Copy link

When the server is writing the file to disk, the file name generated is referencing a post var that doesn't exist:

cb(null, req.body.chefname + "_" + req.body.foodname + req.body._id + "." + file.mimetype.substring(6,file.mimetype.length));

req.body._id is not set in food-upload.component.js:

const newFoodItem = new FormData();
newFoodItem.append("chefname",this.state.chefname);
newFoodItem.append("price",this.state.price);
newFoodItem.append("foodname",this.state.foodname);
newFoodItem.append("productImage",this.state.productImage,this.state.productImage.name);
newFoodItem.append("description",this.state.description);
newFoodItem.append("ethnicity",this.state.ethnicity);
console.log(newFoodItem);
axios.post('http://localhost:5000/fooditems/add', newFoodItem).then(res => {
console.log(res.data)});

This is leading to all uploads having undefined appended to their names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant