【发布时间】:2018-05-23 07:24:26
【问题描述】:
我要在 Rails 中返回:
render json: { errors: e.response.body.errors }, status: 400
在 JavaScript 中我使用的是 Axios:
axios.patch('/settings/account', {}, {params: {...
} })
.then((e)=> {
...
console.log('submitted')
})
.catch(function (error, res) {
// only get error that gives 400, but not error msg here, res isn't here
console.log(error);
});
如何在我的前端获取e.response.body.errors?
【问题讨论】:
标签: javascript ruby-on-rails error-handling promise axios