Open leviwilson opened 8 years ago
This is what I'm currently using as a workaround (don't judge me :wink: )
angular.module('myApp').run ['$jsonapi', '$q', ($jsonapi, $q) ->
wrappedGet = (original, args...) ->
_.tap original(args...), (model) ->
model.promise = model.promise.then -> $q.resolve(model)
wrappedGetResource = (original, args...) ->
_.tap original(args...), (resource) ->
resource.get = _.wrap _.bind(resource.get, resource), wrappedGet
$jsonapi.getResource = _.wrap $jsonapi.getResource, wrappedGetResource
]
This returns the original model's object
in the resulting promise, rather than undefined
.
Description
I've just started messing around with this library. I was able to get things setup pretty quickly and define a schema for a couple of my resources. Testing in the debug console yielded what I was expecting out of it.
In our app, we use a
resolve
in one of our routes before moving on. I noticed that theAngularJsonApiResource.get
method has apromise
value that is returned; I expected that theresolve
d promise that came back would actually have the sameobject
that is returned from theget
, but it doesn't. It isundefined
.To be clear, the promise resolves accordingly, but it appears that what is actually resolved is the
response.data.meta
, vs. theobject
that I expected.Am I understanding incorrectly how this should work?