Checking for 200 status code before traversing json object, preventing uncaught TypeError