I am working on my first app, based on Ionic and Angularjs connected to Wordpress REST Api.
I need to display the category name, but the WP-API V2 post list (example.com/wp-json/wp/v2/posts) has only the category ids.
In order to get the categories I need to make a second http request to example.com/wp-json/wp/v2/categories
This is my function in the controller to load all posts and it works fine.
var postsApi = $rootScope.url + 'posts';
$scope.loadPosts = function() {
// Get all of our posts
DataLoader.get( postsApi ).then(function(response) {
$scope.posts = response.data;
$log.log(postsApi, response.data);
}, function(response) {
$log.log(postsApi, response.data);
});
but how do I achieve to parse the category id, that i get from example.com/wp-json/wp/v2/posts with example.com/wp-json/wp/v2/categories to get the category name without making a http request every single loop?