【发布时间】:2013-09-03 13:18:27
【问题描述】:
我一直在纠结,难以弄清楚如何将服务器错误消息传递给客户端。
在我拥有的服务器上(简化):
export function get(req: express.ExpressServerRequest, res: express.ExpressServerResponse) {
res.statusCode = 500;
res.send('CUSTOM ERROR MESSAGE');
}
在客户端:
public fetchObject(successF: Function, failF: Function): void {
this.myObj = new MyObj();
this.myObj.fetch({ success: successF, error: failF });
}
private failF(model, xhr, options): void {
// Want to get access to "CUSTOM ERROR MESSAGE"
}
xhr 对象 responseText 为空,statusText 始终为“错误”。
有什么建议吗?谢谢!
【问题讨论】:
标签: node.js backbone.js express typescript