How do js asynchronous operations ensure that the results are returned asynchronously?

  1. in the business scenario, the page loads A first. Before this API is returned, I choose to load the result returned by BMague B very quickly, which will be rendered to the page immediately. When A returns, the page will be redrawn again. How to avoid this problem? I just want the result of B. (the API is the same, but the parameter ABC is different)
  2. Business requirements only need to load the last selection for the last time, and drop-down selections, such as selecting ABC, in turn, only need the result of C.
  3. see that all Synchronize operations are submitted and Synchronize results are returned, which can be achieved with promise.all . However, this is an asynchronous submission operation, so how to ensure the results.
  4. is there any way? after I submit C, kill can also meet the requirement by dropping the AB, that is returning the result. The axios used by the HTTP library, I only need the last result
  5. .
Jun.25,2021

cancel the request initiated by axios


Promise.race


give the request number incremented. When rendering the page, only the data with large numbers can overwrite the data with small numbers, and vice versa.

Menu