Fetch stuff ...checking for a valid response

Here's a button.

(This one barfs.)

Here's annother button.

(This one barfs more politely.)

Here's a third button.

(This one should work.)

navigate my process

related content

The Explanation

Once we start dealing with ThE NeTWoRk we're dealing with a chaos of radio receives and telephone wires and other peoples's computers and whatever else is involved in, like, ThE NeTWoRk, which means there is a non-trivial opportunity for things to go poorly at best, completely wrong at worst. Which is why it's a good idea to check that we get a valid and useable response from The NeTWoRk before we start trying to do things with it.

So in this sample we see what happens when our original getJson() function gets a bad path (standing in for "something went wrong on ThE NeTWoRk"). It barfs! Then we do up a getJsonBetter() function which does the bare minimum to catch the error. We don't do much with the error here, but we could, of course, in a fully developed app.