我正在尝试处理Ember应用程序中的服务器错误。
我在ember应用程序中运行以下代码:
customization.save().catch(function (error) {
console.log(error);
console.log(customization.get('errors'));
console.log(customization.get('errors.length'));
});我的服务器在有效负载中使用以下json响应422状态:
{
"errors":[
{
"code":"app.customization.validationError.duplicateCustomizationName",
"detail":"a customization with same name already exists",
"source":{
"pointer":"customization/name"
}
}
]
}错误为InvalidError,但customization.get('errors.length')始终为0。
我在Ember 2.4.5和Ember DATA 2.4.0中使用了DS.RESTAdapter和DS.RESTSerializer。
我错过了什么?
谢谢
发布于 2016-04-20 19:48:52
好了,我终于想明白了。即使您没有使用DS.JSONAPIAdapter,source.pointer中的路径也必须是JSONAPI样式的。
发送此消息:
...
"pointer":"data/attributes/name"
...解决了这个问题。
我认为指针中的路径引用了对应于模型的实际JSON中字段的路径,但这显然是错误的。
https://stackoverflow.com/questions/36740838
复制相似问题