Rahul Pawar
Rahul Pawar

Reputation: 169

TypeError: commonService.restDataService is not a function

After ran the project I got commonService.restDataService is not a function error. Please help me into this. Thanks in advance.

(function() {
    'use strict';
    angular.module('formlyApp').factory('LoginService', ['$http', 'SessionService', 'commonService', 'AlertService',
      LoginService
    ]);

    function LoginService(SessionService, commonService, AlertService) {

      commonService.restDataService(LOGIN_TOKEN_URL, data, null, clientName).then(function(response) {
        if (response.data.jwt) {
          SessionService.saveToken(response.data.jwt);
          successHandler();
        } else if (response.data.responseCode == 452) {
          AlertService.addAlert('Invalid credentials');
        }
      }, function(response) {
        if (response.status === 452) {
          AlertService.addAlert('System Error');
        } else {
          AlertService.addAlert(response.data.message);
        }
      });

Upvotes: 1

Views: 227

Answers (1)

Anik Islam Abhi
Anik Islam Abhi

Reputation: 25352

You have missed $http in the parameter

Just convert this

function LoginService(SessionService, commonService, AlertService)

to this

function LoginService($http,SessionService, commonService, AlertService)

Upvotes: 1

Related Questions