Check if res is nil before trying to read body in healthcheck