I'm trying to use Hacker News API , i am able to call the API and make the request to fetch the stories. As per their API documentation the source URL must contain the ID(required) to access the stories' content, I am getting the correct URL in the console and clicking on the URL gives the appropriate JSON but beyond that I am unable to use/call the JSON content like author name,title etc.
JS CODE:
var records;
var userRecords;
var fileJson;
var startRequest = new XMLHttpRequest();
var sourceUrl = "https://hacker-news.firebaseio.com/v0/";
var sourceUrlAdd = "showstories.json";
var finalURL = sourceUrl + sourceUrlAdd;
startRequest.open("GET",finalURL);
startRequest.onload = function() {
fileJson = JSON.parse(startRequest.responseText);
for(var i = 0 ; i < fileJson.length; i++) {
userRecords = sourceUrl + fileJson[i] + ".json";
}
}
startRequest.send();
How do I make it work??