Return problem

problem description

found a strange problem that the polling request could not be called

the environmental background of the problems and what methods you have tried

when I was polling to call a method, I found that the code could not run into the body of the method (upInitialize is the method that was called by polling), and I could not output the first line of console in the method. When I removed the respondsJudge, everything was normal again after the method called (if (res)).

related codes

/ / Please paste the code text below (do not replace the code with pictures)
/ / call the polling method

   componentDidMount() {
        this.initialize();
        loopReq("abcd",this.upInitialize);
    }
    //
     upInitialize =() =>{
        energyStorageInformation_img()
            .then(res => {
                if (respondsJudge(res)) {
                    this.setState({ energyStorageInformation_img: res.data.storageInfo })
                }
            });       
            }
     //respondsJudge
     export function respondsJudge(res){
  return res
}
//
export function loopReq(timerName,reqFn){
    window.myTimer = window.myTimer? window.myTimer:{};
    window.myTimer[timerName]=window.setInterval(()=>{
        reqFn();
    },Config.dataTimer);

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

I wish I knew why

Apr.21,2021

The code given by

< del > has no place to call the loopReq method. < / del >

modify to:

 window.myTimer[timerName]=window.setInterval(reqFn, Config.dataTimer);
Menu