0
我嘗試從南希錯誤信息返回到基於角2Angular2和Nancy:處理錯誤消息
我南希服務器代碼的Web應用程序:
private dynamic GetSolution(dynamic arg)
{
string solutionName = arg.name;
if (solutionName == "error")
{
var response = Json(new {message = $"error"});
response.StatusCode = HttpStatusCode.BadRequest;
return response;
}
return Json(solutionService.GetSolutionByName(solutionName));
}
在客戶端與接下來的工序響應代碼:
onButtonClicked(name: string): void
{
this
.solutionsService
.getSolutionByName(name)
.subscribe(
p=>this.showMessage(p.title),
p=>this.showError(p.message));
//this.refresh(true);
}
如果效應初探與狀態200 - 我接收預期的對象(字段ID和標題的溶液),
我該怎麼辦了?