Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net WebApi OData + breeze => [Q] Unhandled rejection reasons (should be empty)

I have a .net 4.5 Web Api with OData EntitySetController

In client side I got the following js files loaded

jquery.min.js
q.min.js
datajs-1.1.1.min.js
breeze.debug.js
toastr.min.js
angular.js

when I call the following javascript

breeze.config.initializeAdapterInstance("dataService", "OData");
var manager = new breeze.EntityManager(serviceName);

var query = breeze.EntityQuery.from("Customers");

return manager.executeQuery(query).then(success).fail(fail);

function success(data) {
  $log.info("Retrieved " + data.results.length);
  return data.results;
}

function fail(data) {
  $log.info("error " + data);
}

I see the following in my chrome network tab showing metadata and the json data are coming back nicely...

Request URL:http://localhost:49971/odata/$metadata
Status Code:200 OK, 1.8KB

Request URL:http://localhost:49971/odata/Customers
Status Code:200 OK, 3.3KB

BUT the success callback never fires, the fail callback gets executed. Can any one help please? All I see is

XHR finished loading: "http://localhost:49971/odata/$metadata". datajs-1.1.1.min.js:14
XHR finished loading: "http://localhost:49971/odata/Customers". datajs-1.1.1.min.js:14
[Q] Unhandled rejection reasons (should be empty): 
[Error]
length: 0
__proto__: Array[0]
 q.js:1010
error Error: OK 

I then need to databind these to a ng-grid, ng-form and then finally send them back to database to serverside...

Some more code and screen shot

breeze.EntityQuery
  .from("AddressTypes")
  .using(new breeze.EntityManager(serviceName))
  .execute()
  .then(function(data) {
    console.log(data); // never gets here very wierd
  }).fail(function(e) {
    console.log(e); // shows an error object with the AddressType Array
  });

I see the AddresTypes array in fail callback...

update: I have temporarily switched to a BreezeContoller instead of EntitySetController in the backend, and commented out breeze.config.initializeAdapterInstance("dataService", "OData"); And I get my array in successCb. So I think I can infer I am running into trouble with DataJS. Really would like to stick with EntitySetController though...

like image 322
August Bloom Avatar asked Aug 01 '13 06:08

August Bloom


1 Answers

I had the same problem. As it turned out, going back to datajs 1.0.3 seemed to work. However, doing that resulted $expand to not work (the server works, but breeze doesn't handle it the navigation properties -> regardless its multiplicity).

I must say, I am terrible looking for a STABLE breezejs equivalent.

like image 101
Tomer Avatar answered Sep 21 '22 18:09

Tomer