Help

Re: How to get info out of the JSON that an API delivered

3488 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Ron_Daniel
7 - App Architect
7 - App Architect

I’m a total newbie to JavaScript, and pretty proud of myself that I’ve figured out how to connect to my company’s API to get store information.

console.log(await storeInfo.json());
is displaying all of the JSON returned from the API call, but now how do I get that data out of the JSON?

Example:

CONSOLE.LOG

  1. :arrow_forward: (1) [Object]
  2. :arrow_forward: 0: Object
    1. StoreNumber: “1234”
    2. StoreName: “Joe’s Market”
    3. :arrow_forward: StorePhoneNumbers: Array(2)
    1. :arrow_forward: 0: Object
    2. Description: “Fax”
    3. PhoneNumber: “800-555-1212”
    4. :arrow_forward: 1: Object
    5. Description: “Landline”
    6. PhoneNumber: “800-555-2121”

How can I pull the store name and phone numbers out into individual variables that I can do stuff with?

10 Replies 10

Congrats! :tada:

Looks like the top level of the data is an array, versus an object. It was hard to tell in your initial post. Glad you figured it out.