Reputation: 759
I'm using AngularJs in a big proyect. I need to create a page that loads a video, said video URL comes from a GET request to the backend.
This is a very newbie question, but I cannot figure it out!
This is the function that GET the video URL:
function getInstructionalVideoUrl() {
var url = baseUrl + 'instructionalvideo';
return $http.get(url)
.then(success)
.catch(fail);
function fail(response) {
exception.catcher('XHR Failed for start setup')(response.data);
return $q.reject(response);
}
function success(response) {
return response.data;
}
}
When I assign the result of that function to a variable and I log that variable to the console, this is what I get:
How can I get THAT value? Is this function returning a Promise?
I'm failing to recognize exactly what I am getting back.
Upvotes: 1
Views: 1612
Reputation: 314
Here's the angular documentation on promises with some examples: https://docs.angularjs.org/api/ng/service/$q
At first glance, the getInstructionalVideoUrl doesn't seem to be passing back the promise correctly in the success case. If it were you could do something like this...
getInstructionalVideoUrl()
.then(function(video){
//read the video
},
function(error){
/*handle error*/
});
Upvotes: 2