我想问您如何在前端接收/显示在后端生成的错误消息。
在java spring后端中,类似于:
return new ResponseEntity<>(new Exception("This is what I want to show in the front"), HttpStatus.CONFLICT);
在vue.js前端,类似这样的内容:
axios.post(registerUrl, formData, backendOptions).then(
response => {
console.log(response.data); //Irrelevant for this example
}).catch(err => {
console.log(err);
//Displays 'Error: Request failed with status code 409'
//Instead of: 'This is what I want to show in the front'
});
谢谢!
1条答案
按热度按时间ua4mk5z41#
试试这个。