Mini Program's request to join session3rd

is currently developing a Mini Program, based on mpvue, there is a request problem has been perplexed for a long time, ask God for advice.

the problem is that after starting Mini Program, call wx.login to get the code and pass it to the backend, then get the session3rd, and stipulate that this parameter must be included in each request. But now, when you enter Mini Program, you will request a request from the home page or other pages. At this time, the session3rd is also asynchronous and has not been cached yet. This parameter is not taken when other requests occur. I would like to know what to do with it. To make sure that you don"t start other requests until you get the session?

Mar.29,2021

encapsulate all the requests at once, temporarily store the request, throw a Promise object, wait until the wx.login and request the server interface to obtain the session3rd parameter, and then send the temporary request.
this ensures that all requests will not be initiated until the session3rd is obtained

Supplementary Code links

first of all, some requests that depend on the session3rd parameter are issued together with the request to get session3rd, which is itself a logical problem

so here is a simple example. Hold the request until the previous request is successfully initiated: git address


I have the same problem. Mini Program needs at least two asynchronous requests from the beginning (code in exchange for session3rd,session3rd as the request header parameter for userInfo).
should actually be three asynchronous requests to be exact. Because the wx.login method to take code is also asynchronous.

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-1e4c958-44eca.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-1e4c958-44eca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?