I have an Angular JS application with Breeze and Nancy (self-hosted with Owin). I've figured out how to get data from server with Breeze, but now I'm trying to save changes using Breeze and have problems with it. I've seen MVC examples like:
[HttpPost]
public SaveResult SaveChanges(JObject saveBundle)
{
return _repository.SaveChanges(saveBundle);
}
But obviously I can't do the same with Nancy. My application sends POST request to SaveChanges but then breaks with TypeError: undefined is not a function and Cannot read property 'map' of undefined
At the moment I simply return the same Json I get in Request, as I have no idea what the response should be:
Post["/breeze/SaveChanges"] = parameters =>
{
string response = "failed";
try
{
response = new StreamReader(this.Request.Body).ReadToEnd();
}
catch (Exception ex)
{
//TODO handle
}
return Response.AsJson(response);
};
I'm not sure if it breaks because it receives incorrect request from server or because I haven't set something up correctly.
Can anyone help with it?