Q:

How can I get my Angular $http request to return a response? I've tried callback functions and promises

Been stuck on this for hours now and I've tried every example I've come across without any success.
I have a simple form on my portfolio that sends me an email when it's submitted. In that regard, it works perfectly. However, I want some kind of response so that I can display either a success or error message on the page so the user can tell that their message went through.
Here is my controller code:
$scope.sendMail = function(name, address, message) {
    var deferred = $q.defer();
    $http({
      url: '/send',
      method: 'GET',
      params: {name: name, address: address, message: message}
    }).success(function(response) { 
      console.log('Worked!');
      deferred.resolve(response);
    }).error(function(response) {
      console.log('Did not work!');
      deferred.reject(response);
    });
    return deferred.promise;
  }

Here is where I'm sending the request in my node server.js file:
app.get('/send',function(req,res){
  var mailOptions={
    to : 'ClaytonAlanKinder@gmail.com',
    subject : 'Message from: ' + req.query.name + ' at ' + req.query.address,
    text : req.query.message
  }
  console.log(mailOptions);
  transporter.sendMail(mailOptions, function(error, info){
    if (error) {
      console.log(error);
    } else {
      console.log(info.response);
    }
  });
});

I'm tried all sorts of returns, callbacks, defers, and promises, but nothing seems to be working.
Any and all help would be greatly appreciated.

A:

you don't need var deferred = $q.defer(); or either of the success and error callbacks, $http already returns a promise, you just have to use it.
$scope.sendMail = function(name, address, message) {
  ContactService.sendMail(name, address, message).then(function(response){
    $scope.successfulSend = response;
  },function (e) {
    console.warn('An error has occurred.', e);
  });
}

.service('ContactService', function($http, $q) {
  this.sendMail = function(name, address, message) {
    return $http({
      url: '/send',
      method: 'GET',
      params: {name: name, address: address, message: message}
    });
  }
});

