1

I'm trying to get from API the data and don't know how.

So I am trying to use this API https://api.abalin.net/get/today?country=cz and don't know really how.

<div id="data"></div>

<script type="text/javascript">
    $.get("https://api.abalin.net/get/today?country=cz", function(data){




            $("#data").append(data.results[0].name_cz );
        }           
    )
</script>
Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

2

The response is an object that has property data and not results.

$.getJSON() is also a better ajax shortcut method for making json GET requests.

$.getJSON("https://api.abalin.net/get/today?country=cz", function(res) {
  console.log('name_cz = ', res.data.name_cz);
  console.log('month = ', res.data.month);
  
  $('#data').text(res.data.name_cz);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="data"></div>
charlietfl
  • 170,828
  • 13
  • 121
  • 150