I´m getting that error message when I´m trying to format a JSON Object, I´m trying to store in a variable the population in this API response:
[
{
"countryCode": "ru",
"countryName": "Russia",
"population": [
{
"year": "2016",
"data": "144342396"
}
]
}
]
It´s my first time working with JSON so I´m sorry if it´s just a silly mistake. :(
function definir_tabla(id_tabla) {
var codigo;
switch (id_tabla) {
case "tabla_rusia":
codigo = "ru";
solicitar_datos(id_tabla,codigo);
break;
}
}
function solicitar_datos(tabla, codigo_iso) {
var habitantes = $.get('http://inqstatsapi.inqubu.com/?api_key=xxxxxxxxxx&data=population&countries=ru&years=2016');
var numero=JSON.parse(habitantes);;
console.log(numero);
document.getElementById(tabla + "_habitantes").innerText = habitantes;
}