I seem to be facing a bit of a hurdle in executing an HTTP GET request and retrieving the data properly in JavaScript. The goal is to attach this data to the global window variable, but I'm encountering some difficulty.
Here is the code snippet for the HTTP call:
$http.get("production/dashboard?dashboard_type=A").success((data) ->
$scope.pods = data;
window.pods = $scope.pods.toJSON;
window.type = 'A';
alert(window.pods)
alert(window.type)
alert "success1"
return
).error (data, status, headers, config) ->
return
When I run this code, I am seeing the following alerts:
1. Alert("undefined")
2. Alert("A")
My understanding was that the promise of the HTTP request would be resolved once the response is received. Upon checking the Network tab, I can confirm that JSON data is indeed being returned as the response. It feels like I'm missing something straightforward...