check if the user has internet before calling the api