How to engage user if some API is taking time on website or app

What are the methods using which we can engage the user on website or mobile app page where some backend API take more time to provide the output.