I am new to CoffeeScript and am trying to code a promise in a function. I used this reference - Chaining Promises in Coffeescript . But when I code it, I get the error I type .then (response)
- TypeError: getter.then is not a function
and I get this error if I type .then(respone)
- response is not defined
. Here is the code for the particular service. Help would be appreciated.
angular.module("deloitte.closeCalendar").factory('labPreferencesService', [ '$location','baseApiService','$routeParams','$translate','labService',( $location, api, $routeParams, $translate, labService) ->
service = {}
selectClient = new Object();
service.setClient = (client) ->
localStorage.clear();
delete selectClient[0];
selectClient[0] = client;
localStorage.setItem('name', JSON.stringify(selectClient[0]));
console.log("Name Set!")
service.getClient = (scope) ->
if (Object.keys(selectClient).length == 0)
console.log("Select Client was empty!")
getter = localStorage.getItem('name')
getter.then (response) ->display = response;
console.log (display);
else
console.log("Select Client had data !");
console.log(selectClient);
return service
])