Skip to content

Uploaded food items reference non-existent request data #27

@danny1461

Description

@danny1461

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions