Hive coding #3b

How to get last Post with comments

by hive_coding

HTML

<html>

  <head>
    <script src="https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  </head>
  <body>

    Username: <input id="username" value="freegifts"><button id="btnShowAccount">Get Postingn</button>
    <h2>Ausgabe/Output:</h2>
    <div id="log"></div>

    <script>
      $("#btnShowAccount").click(function() {

        let username = $("#username").val();
        hive.api.getDiscussionsByAuthorBeforeDate(username,null,null,10, function(err, result) {
        
        for(i=0;i<result.length;i++){
				
        	if(result[i].children>0){
                hive.api.getContentReplies(username, result[i].permlink, function(err, result) {

                  for(j=0;j<result.length;j++){
                      let r=result[j];
                      $("#log").append("<div>"+r.author+"</div>");          
                    }

                  console.log(err, result);
                });
                break;
            }
          }
          console.log(err, result);
        });
      });
    </script>
  </body>
</html>