It takes too much time for Mini Program to get token, but the home page is a request that needs token. Is there any good way to solve it?

you need to use some information in openid and userinfo to obtain token, so app.js needs to wait for these two APIs to get data before sending a request to acquire token. But what if you need to send a request and need token, as soon as you enter Mini Program"s home page, but what if you haven"t got token yet?
my current practice is to load wx.showLoading for three seconds in onLoad when I enter the home page, and then perform the operation, but sometimes I can"t guarantee that three seconds is enough. Is there a better way

Mar.14,2022

my current practice is to make a judgment every 200ms (the specific time is set by myself), to determine whether the token, has been obtained, and to make a request if yes, instead of waiting for 200 more. You can solve this problem. The specific time is related to performance. The shorter the time is, the faster the response is, but the performance is not so good. The longer the time is, the slower the response is, but the better the performance is. It is said on the Internet that you can use Promise to achieve asynchrony into Synchronize, but you need to introduce js, to see how you choose.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e59afb-44285.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e59afb-44285.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?