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

1

6

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...

Brinson answered 1/8, 2013 at 6:36 Comment(5)
Are there any other error messages? It seems strange that the error message is "OK".Voltaic
Adding .end() after fail() will remove the "Unhandled rejection reasons (should be empty)"Voltaic
` .then(function(data) { console.log(data); }).fail(function(e) { console.log(e); }).end();` Uncaught TypeError: Object [object Object] has no method 'end'Brinson
Ah sorry it's .done() not .end()Voltaic
out put is now 'Should be empty: [] q.js:621'. I do understand that output is by design from Q.js. But the fact remains the successCb never gets called and the data embeeded in the failureCbBrinson
E
1

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.

Embroidery answered 16/10, 2013 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.