2 fetch sequence execution

When writing the front-end, there is a requirement that fetch updates first, and then fetch query elements. These two must be executed in order. But because fetch is asynchronous operation, you cannot write two fetches in a simple sequence.

The reason for the error: It takes longer to update the fetch than the query fetch . Even if the update fetch is written before the query fetch, the two are performed at the same time. The result is that the query is first updated and then updated, which does not meet the requirements.

Solution: Write the query fetch in the callback function then of the update fetch, so that you can ensure that it is updated first, and then the query is performed. Of course, because there is a callback function, updating fetch also needs to add a valid return value.
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/livingsu/article/details/106584780