lundi 22 novembre 2021

Accessing JSON data through API with js

WHY! Why is this not working. I am using the weatherbit api, and trying to simply get the uv index. Mind you, in a browser the proper link displays all the information but I can not get it to work through js, putting it through to a div. I replaced the actual request data with (nameOfData) for privacy, I assure you that there is no problem with the parameters specific.

$getJSON('https://api.weatherbit.io/v2.0/current?lat=(Lat)&lon=(Lon)&key=(Key)', function(data) {
    // JSON result in `data` variable
    $(".UV").html(data.data[1].uv);
});

Please help.




Aucun commentaire:

Enregistrer un commentaire