# Hi guys, the console is showing me the result "undefined" about the api

**URL:** <https://discourse.processing.org/t/hi-guys-the-console-is-showing-me-the-result-undefined-about-the-api/24154>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [September 27, 2020, 2:10pm UTC](https://discourse.processing.org/t/hi-guys-the-console-is-showing-me-the-result-undefined-about-the-api/24154 "2020-09-27T14:10:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kappo25](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kappo25/32/10700_2.png) [@kappo25](https://discourse.processing.org/u/kappo25)\
**Post date:** [September 27, 2020, 2:10pm UTC](https://discourse.processing.org/t/hi-guys-the-console-is-showing-me-the-result-undefined-about-the-api/24154/1 "2020-09-27T14:10:42Z")

</div>

```auto
var weather;

function setup() {

  loadJSON(
    'https://restcountries.eu/rest/v2/capital/tallinn',
    gotData
  );
}

function gotData(data) {
  weather = data;
}

function draw() {
  background(0);
  if (weather) {
   console.log( weather.timezones);
   
  }
}

```

[[https://restcountries.eu/rest/v2/capital/tallinn](https://restcountries.eu/rest/v2/capital/tallinn)] is the API where I am taking the information,

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 27, 2020, 3:11pm UTC](https://discourse.processing.org/t/hi-guys-the-console-is-showing-me-the-result-undefined-about-the-api/24154/2 "2020-09-27T15:11:14Z")

</div>

## RestCountries.eu/rest/v2/capital/tallinn

```javascript
[
  {
    "name": "Estonia",
    "topLevelDomain": [
      ".ee"
    ],
    "alpha2Code": "EE",
    "alpha3Code": "EST",
    "callingCodes": [
      "372"
    ],
    "capital": "Tallinn",
    "altSpellings": [
      "EE",
      "Eesti",
      "Republic of Estonia",
      "Eesti Vabariik"
    ],
    "region": "Europe",
    "subregion": "Northern Europe",
    "population": 1315944,
    "latlng": [
      59,
      26
    ],
    "demonym": "Estonian",
    "area": 45227,
    "gini": 36,
    "timezones": [
      "UTC+02:00"
    ],
    "borders": [
      "LVA",
      "RUS"
    ],
    "nativeName": "Eesti",
    "numericCode": "233",
    "currencies": [
      {
        "code": "EUR",
        "name": "Euro",
        "symbol": "€"
      }
    ],
    "languages": [
      {
        "iso639_1": "et",
        "iso639_2": "est",
        "name": "Estonian",
        "nativeName": "eesti"
      }
    ],
    "translations": {
      "de": "Estland",
      "es": "Estonia",
      "fr": "Estonie",
      "ja": "エストニア",
      "it": "Estonia",
      "br": "Estônia",
      "pt": "Estónia",
      "nl": "Estland",
      "hr": "Estonija",
      "fa": "استونی"
    },
    "flag": "https://restcountries.eu/data/est.svg",
    "regionalBlocs": [
      {
        "acronym": "EU",
        "name": "European Union",
        "otherAcronyms": [],
        "otherNames": []
      }
    ],
    "cioc": "EST"
  }
]

```

Your JSON access issue is very similar to this very recent topic below:

> [@How do I draw a circle based on my JSON data information in p5.js?](https://discourse.processing.org/t/how-do-i-draw-a-circle-based-on-my-json-data-information-in-p5-js/24146):
>
> So, I’m trying to grab data from my JSON file to my code and display the circle size according to the number on my JSON file. So far this is the code. var data; var instagram, snapchat, messenger, facebook, email, instagramCol, snapchatCol, messengerCol, facebookCol, emailCol; var sizeMultiplier = 20; var time, size; function preload (){ data =loadJSON (“Sunday.json”); } function setup() { createCanvas (windowWidth, windowHeight); background (255); instagramCol = color (142, 68, 173)…

So I’m just gonna recapitulate from my previous answer there:

- The outer datatype of this API JSON stored in variable _weather_ is JSONArray.
- Inside that we find only 1 big JSONObject entry.
- That JSONObject contains many properties, and 1 of them is _timezones_.
- And that _timezones_ property points to a JSONArray containing 1 String entry, which is “UTC+02:00”.
- So in order to reach that particular property and its single String content we can go like this:  
`weather[0].timezones[0]` or `weather[0]['timezones'][0]`

---

<div class="post-metadata">

**Author:** ![kappo25](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kappo25/32/10700_2.png) [@kappo25](https://discourse.processing.org/u/kappo25)\
**Post date:** [September 27, 2020, 3:30pm UTC](https://discourse.processing.org/t/hi-guys-the-console-is-showing-me-the-result-undefined-about-the-api/24154/3 "2020-09-27T15:30:45Z")

</div>

thank youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
