Introduction

In this lesson, we will look at:

  • Inspecting the results of API calls.
  • Skipping certain objects when looping over an array of objects.

Inspecting the results of API calls

When making API calls, the most important thing to do is to inspect the JSON that the call returns.

You can’t make assumptions about what the JSON will contain and what properties you can access.

You can use a simple console.log or software like Postman.

Code from the video.

Skipping certain results

Sometimes you will want to ignore certain objects in an array. Perhaps they are missing specific properties, or the properties have useless values.

We can do this using the continue keyword inside a for loop.

continue causes the loop not to execute the code in its current iteration and jumps to the next iteration.

Like break, continue cannot be used inside a forEach function.

  • break - exit the loop entirely.
  • continue - skip this particular iteration of the loop.

Code from the video.


Lesson Task

Brief

There are practise questions in the master branch of this repo.

Attempt to answer the questions before checking them against the answers branch of the repo.

Tags: