0

I am trying to send multiple requests to a customized HTTP server which sends response only for a few requests. The js which I wrote use Axios to send multiple requests and stop sending the requests as soon as one response is received. My script is as follows:

async function poll() {
    let countOfError = 0;
    const maxErrors = 10;
    let resp = null;

    while (true) {
        try {
            resp = await axios.get('http://localhost:8080/ubuntu_default.html', { withCredentials: true });
            
            //check if resp is "success" then break;    
            if (resp.data.success) break;            
        } catch (e) {
            //console.error(e);  optional
            countOfErrors += 1;
            if (countOfErrors > maxErrors) break;
        }
    }

    return resp.data;
}

However, I am receiving the following error in the console:

"DevTools failed to load SourceMap: Could not load content for http://localhost:8080/axios.min.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE"

  • I think this has something to do with the fickleness of error handling concurrent `async/ await` calls. [This answer](https://stackoverflow.com/a/54291660/11047824) has *a lot* to say about it, if you can wade through it. The gist is that you may want to rewrite this using promises to handle your errors well. – zcoop98 Jul 29 '20 at 15:47
  • 404 on SourceMaps should never affect your program – Vinay Jul 29 '20 at 16:06

0 Answers0