How to use queues in JS or react?

axios.post ("/ api/php/user/findPsw.json",params). Then ((res) = > {

)
        var jsonObj = JSON.stringify(res.data)
        var jsonTemp="[{"
        var checkPsw = jsonObj.substring(jsonObj.indexOf("password")+11,jsonObj.indexOf("roleIdList")-3).split("0").join("")
        if(checkPsw===password){
            this.setState({passwordCheck:true})
        }
    }).catch((err)=>{
        alert(err.status)
        console.log(err.status)
    })
    
    if(this.state.passwordCheck){ // 
        alert("")
        //...
        }
        

as in the above code, I check whether the checkPsw in the json is the same as the password extracted from the page in the response then method of the axios request, so that under the passwordCheck, of setState, it is judged that if it is true, I will log in to the page, but this passwordCheck value, due to the running order, always starts to judge that the login demo I wrote has to press two clicks to log in before the then method is executed before the setState is executed before it will jump. I would like to ask the gods, whether you can use the queue to execute the axios request block, so that the execution of the setState block is finished, and then to judge this.state.passwordCheck, on this issue, I react+antd just started to compare, the answer please code as simple as possible easy to understand. *

italic text

*


Ajax and setstate are both asynchronous
. If you put the login logic in checkPsw=password , you don't have to judge it again, or put it in the callback

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