Search code examples
angularjssslhttpsiis-expressvisual-studio-cordova

How to post on angularjs in https


here is my angularjs request whenever I submit a request it returns error and no delay.

   var req = $http({
            method: 'POST',
            url: 'https://localhost:44300/authentication/login',
            data: { UserID: Username, Password: Password },
            dataType: "json"
        });

        req.success(
            function (result) {
                 alert('success');
            });
        req.error(function (result) {
                 alert('something went wrong');
        });

Thanks in advance.


Solution

  • thats how I do and it always works fine

    var deferred = $q.defer();
    var url = 'your url';
    $http({
           method: 'POST',
           url: url,
           data: {}
          })
          .then(function(data, status, headers, config) {
                deferred.resolve(data);
          })
          .catch(function(data, status, headers, config) {
                deferred.reject(msg);                        
          });
    
          return deferred.promise;