Search code examples
angularjslocalforage

Return LocalForage Promise


I was wondering how I would return the token key in this query

 function inspectionResource($resource, $localForage) {
    return $resource("https://blah.org.uk/inspection/v1/:fieldofficernumber/booked", {fieldofficernumber:'@fieldofficernumber'}, {
        'query': {
            method: 'get',
            isArray: true,
            headers: { 'Authorization': 'Bearer ' + $localForage.getItem("token") }
        }
    });
}

Im not sure how to use the .then(function(value){} in the headers.


Solution

  • return localForage.getItem("token").then(function (token) {
      return $resource(...);
    });