You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
I keep wanting to use the transform response property of the config object with an http service wrapper. The docs claim that the transformResponse is fired when there is a successful status message. Instead, I get no transformResponse firing.
I have tests that show OK, 200, works, but 204 with null or undefined data does not.
The reason why is I'd like to set up default data, but I cannot with this current behavior (I took out a few things, but this should get the gist:
describe("When using the SubNavServiceUri",function(){varserviceUri;varrequestUri="/api/aliens";varcollection=null;varhttpBackend;beforeEach(function(){module("superSiteApp");inject(function(_$httpBackend_,_SubNavServiceUri_){httpBackend=_$httpBackend_;serviceUri=_SubNavServiceUri_;});});afterEach(function(){httpBackend.verifyNoOutstandingExpectation();httpBackend.verifyNoOutstandingRequest();});it("and NoContent it should return empty collection",function(){// set up correct end pointhttpBackend.expectGET(requestUri).respond(HttpStatusCode.NoContent);varactual;serviceUri.get(requestUri).then(function(result){actual=result.data;});httpBackend.flush();expect([]).toEqual(actual);expect(0).toEqual(actual.length);});
...
service("SubNavServiceUri",["$http",function($http){varisNullOrUndefined=function(item){returnitem===null||item===undefined;};vartransformData=function(data){varresult=[];returnresult;};varget=function(uri){varobject={cache: false,transformResponse: function(data,headersGetter,status){console.log("howdy ");console.log("headersGetter "+headersGetter);console.log("status "+status);if(isNullOrUndefined(data)){return[];}else{returntransformData(data);}}};return$http.get(uri,object);};return{"get": get};
...
I keep wanting to use the transform response property of the config object with an http service wrapper. The docs claim that the transformResponse is fired when there is a successful status message. Instead, I get no transformResponse firing.
I have tests that show OK, 200, works, but 204 with null or undefined data does not.
The reason why is I'd like to set up default data, but I cannot with this current behavior (I took out a few things, but this should get the gist: