var result = dataService.makeHttpRequest("GET", "/documents/checkfilename/", null,
function (response, status, headers, config) {
// I can see `true` if I alert(response); here
// I want to return the contents of response because
// it's a true/false and would perform tasks based
// on it being true or false.
return response;
});
alert(result); // this should alert `true` or `false` but is `undefined`
Why does alert(result) always return undefined
? I know that response
in the above function has true
or false
, I am able to alert it; but, I want to return it and do things only when it is true.
The dataService.makeHttpRequest
service function looks like the following:
dataService.makeHttpRequest = function(requestType, urlString, dataObject, successFunc, errorFunc) {
$http({
method:requestType,
url:$rootScope.serverAddress+urlString,
data:dataObject
})
.success(successFunc)
.error(errorFunc);
};