only invoke api if state is ready.