Fixed crash when API returns null.

Fixed issue with solution from @pirtil.