Search code examples
javascriptajaxtumblr

Tumblr API - 'tag crawling' script doesn't show the images


I have this so far. It should grab the images from 'cyberpunk' tag and post it to <body>, but it doesn't work. Why? More information about Tumblr API can be found here.

<script>
  $(document).ready(function (){
    var link = "http://api.tumblr.com/v2/tagged?tag=cyberpunk";
    $.ajax({
      type: "GET",
      url : link,
      dataType: "jsonp", 
      data: {
          api_key: "PgAKpKfv1Tcjo1uhsKEuriThhwH9XDJonRobaGwckw8RJt2tos"
      }
    }).done(function( data ) {
      $.each(data.response.posts, function(){
        var _photos = this.photos;

        $.each(_photos, function(){
          $('body').append("<img src='" + this.original_size.url + "'/>");
        });
      });
    });
  });
</script>

Solution

  • its just data.response, not data.response.posts, so

    //your code...
    //..
    
     $.each(data.response, function(){ //
    //.. rest of your code