Make the resource work propery with $http promises