I am trying to get the information from an api with JSON format, with jQuery. I can get or display the first index "meta" but not the second "results" (check the url)
{
"meta":{
"name":"openaq-api",
"license":"CC BY 4.0",
"website":"https://docs.openaq.org/",
"page":1,
"limit":100,
"found":160
},
"results":[
{
"location":"Aberdeen",
"city":"Aberdeen",
"country":"GB",
"count":23206,
This is what I can display in the html:
openaq-api
CC BY 4.0
https://docs.openaq.org/
1
100
160
[object Object]
[object Object]
[object Object]
[object Object]
I want to get in jQuery because later I want to display with this data a line chart, like Morris.js https://morrisjs.github.io/morris.js/index.html#getting-started
This is de code:
$.getJSON( "https://api.openaq.org/v1/locations?country=GB", function( data ) {
var html = [];
$.each( data, function( index, hees ) {
$.each( hees, function( att, val ) {
html.push( "<li id='" + att + "'>" + val + "</li>" );
});
});
$( "<ul/>", {
"class": "my-new-list",
html: html.join( "" )
}).appendTo( "#locations" );
});
Any idea?