const getDataFromServer = async () => {
var response = setInterval(()=> {
var w = axios.get('/yet')
if(w.data === 'done') {
nextStep();
clearInterval(response)
}
}, 1000);
};
"这段代码所做的就是不断询问服务器是否已经完成了处理(在我的例子中,这是使用python、flask.的文本到图像的生成).(每秒钟),一旦它得到‘完成’响应,它应该立即停止询问,并继续下一步(它是表单向导风格的Reaction应用程序)."我在开发人员工具中判断了浏览器的网络选项卡,响应是正确的(在过程完成后更改为‘完成’),但它不会进入下一步,也不会停止询问.
I just need this axios.get to stop as soon as it gets 'done' response.
个