Vue:Error in render “TypeError Cannot read properties of undefined (reading ‘id‘)“

created at 05-29-2022 views: 36

error

Error in render “TypeError Cannot read properties of undefined (reading ‘id‘)“

In the process of my own development, I encountered this problem, and I reported an error when Vue wrote delete to delete axios.

solution

 async deletePriceList(){
    console.log(this.inputDatas.id);
    // const {data: results} = await this.$http.post('/section/abc',{params:{id:this.inputDatas.id}}); 
    //This format is not very clear where there is a problem, but later changed to the following method to solve it, using the splicing method.
    const {data: results} = await this.$http.post('/section/abc?id='+this.inputDatas.id)
    if(results.status !== 200) return this.$message.error("failed to add")
        // reload data
        this.getDate(),
        console.log("deleted successfully!")
}

After changing to this, the front end was solved, but it started to report 403 all the time. In general, it was a code problem that resulted in no access rights, so I modified the back-end code;

//deletemapping()// When using this annotation, it should be subject to some kind of permission, so if you encounter such a similar problem, you can try this method.

@RequestMapping("/abc")
public SysResult deleteSection(Integer id){
    kzSectionService.deleteSection(id);
    return SysResult.success();
}
created at:05-29-2022
edited at: 05-29-2022: