I try to call $http service within functions so I don't get nested callbacks. Without function scope it look like this:
$http.post('/verify_stripe_token', {email:$routeParams.email,token:$routeParams.t})
.then(function(response) {
console.log(response.data) // return 1
});
I want to use if(valid_token() == 1){} so I tried
function valid_token(){
$http.post('/verify_stripe_token', {email:$routeParams.email,token:$routeParams.t})
.then(function(response) {
return response.data;
});
}
Nothing worked? I do console.log(valid_token()) I got undefined.