I'd like to ask a question about js timer. I have several ajax interfaces.

problem description

I"d like to ask a question about js timers. I have several ajax interfaces. What"s the difference between defining a settimeout for each interface and merging them into a scheduled task? What kind of performance will be better?

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)

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

Jan.26,2022

it is recommended to define a timer in success success, so that another request will not be initiated because the last API did not return data in time, to prevent blocking


1. Whether the data in each interface needs to be associated, if you need association, you can use timeout to go down one by one. If you do not need association, you can directly cycle through interval. If you think the loop frequency is too fast, you can consider putting it into worker for
2, or combine Promise or async/await to see if it can meet the requirements and better optimize the logic

.
Menu