Sunday, October 22, 2017

AngularJS callback error and is not a function

I have an error in line callback(response.data) telling that callback is not a function. Well, I am new to this and I am trying to figure out how to fix this issue but I am having a tough time. Any idea is appreciated. Thanks

 app.service('NotificationPollService', function ($q, $http, $timeout) {

      var notification = {};
      notification.poller = function (callback, error) {
          return $http.get('api/sample.php').then(function (response) {
              if (typeof response.data === 'object') {
                  callback(response.data);                 
              } else {
                  error(response.data);
              }
              $timeout(notification.poller, 2000);
          });
      }

      notification.poller();

      return notification;
});

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/22/angularjs-callback-error-and-is-not-a-function/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment