AngularJS Wordpress JSON API Plugin returning html instead of json

I'm trying to get recent posts from my wordpress blog but it's returning html instead of json. I want to use json to make it easier to access the blog contents. I already have the plugin installed and activated. Here's what I do to get the posts:

  $http.get('blog/?json=get_recent_posts')
  .success(function(data, status, headers, config){
      $scope.post = data;
      console.log(data);
  })
  .error(function(data, status, headers, config){-
      console.log("unable to access!!!!!!!!!!!");
  });

What's the reason that it's returning html instead of json? Are there any workarounds? Some other posts mentioned using jsonp but that did not work for me either.

Answers:

Answer

I'm likely doing it wrong, but when I form my requests for a Wordpress installation at http://www.example.com/ like this:

http://www.example.com/index.php?rest_route=/my/rest/route/here

I end up getting proper responses back.

I had a heck of a time figuring this out and ended up grokking a URL formatted like that in the HTML returned to me. I was expecting to make requests as http://www.example.com/wp_json/wp/v2/my/rest/route/here , but I only got HTML responses.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.