How to encapsulate a promise into a method that executes sequentially and the chained call returns only one promise?

problem description

this problem is encountered in the nuxtServerInit of the nuxt framework, which is used for server rendering. When this method blocks on the server side and waits for promise to be returned, I want to execute multiple promise, orderly in this method. Because other promise is based on the promise return value of a certain one, the blocking here will not wait for the completion of execution in the then when calling with then (), and the sequential execution cannot be guaranteed with promise.all. Solve

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)
nuxtServerInit (store, {params, route, req}) {/ / it will only block to return promise
const initData = [

on the server side.
store.dispatch("getToken"),//token
store.dispatch("getLawyerByIndex")//token

]
return Promise.all (initData)
}
chain call can only get "getToken", won"t get" getLawyerByIndex", can be obtained with promise.all, but there is no guarantee for sequential execution

what result do you expect? What is the error message actually seen?

Jan.18,2022

I say I don't understand. Since I want to execute in series, follow

directly.
return Promise.resolve(...)
              .then(...)
              .then(...)
              .then(...)
Wouldn't it be better to use the

way?

this process is actually similar to the Array.reduce process, in which the expected results are superimposed in the return value of each then.


construct the interface you want to request into a list
['/ info','/detail'.]
and then request it with a for loop. In the code block of for, await


maybe you need this async/await

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