Add response validation to your APIs code and return a safe fallback when the response is incomplete.
Run your code to see output here...