I am facing an issue with my Wordpress AngularJS theme as it is not loading content using promises. Despite looking at various tutorials on promises and factories, I still cannot get it right and encounter errors whenever I try anything. Can someone provide me with a working example?
Below are the requests that need to be made:
$http.get('wp-json/wp/v2/posts/?filter[name]=' + $routeParams.slug)
$http.get('wp-json/theme/v1/post/' + $scope.post.id)
$http.get('wp-json/wp/v2/media/' + $scope.post.featured_image)
Here is my controller code. Once I understand how to implement promises correctly, I should be able to resolve the issue more easily. Note that the second and third HTTP requests are triggered upon callback of the first request.
app.controller('Post', ['$scope', '$routeParams', '$http', 'service', function($scope, $routeParams, $http, WPService) {
// requests
}]);