The request failed and error.message is the data

Failed to complete friend request. Fortunately, he caught it in his failover callback (you have a fail callback for every server call, right?). Here is what he had:

var getPersons = function (personsObservable) {
    return EntityQuery.from ('Person')
           .using (manager) .execute ()
           .then (querySucceeded) .fail (queryFailed);
}
function queryFailed (error) {
    var msg = 'Error retreiving data. '+ error.message;
    logError (msg, error);
    throw error;
}

error.message just showing JSON data ... that looked something like this:

"[{" $ id ":" 1 "," $ type ":" Person, ProjectName "," Id ": 12," FirstName ":" Bob "," LastName ":" Smith "," Email ":" bs@contoso.com "," Blog ":" http://bs.contoso.com "," Twitter ": ..." 

Wat? He learned error.XHRwhich provides the full AJAX XHR object used for this request. He could see that the HTTP status code was 200 ... that everything was cool from the server. The fact that he had real data pretty much said the same thing.

So why does the breeze fail? How does he diagnose a problem?

+5
source share
1 answer

. , . , Breeze , . . .

fail (1), (2), . , Breeze. , , , .

, ​​ ( querySucceeded). , , . , , , , , , , .

EntityType

. - , JSON . ?

. Breeze. , , -. EntityType?

. , fullName Person. :

metadataStore.registerEntityTypeCtor('Person', null, personInitializer);

function personInitializer(person) {
    person.fullName = ko.computed(function () {
        return entity.firstName() + ' ' + person.lastName();
    });
}

. .

... ...

// "entity" does not exist. Null object error
return entity.firstName() + ' ' + person.lastName();

entity Person, .

, Q fail JSON Person . JavaScript. :

  • Person
  • Person ( )

, , .

, .

+6

All Articles