0

The code below keeps returning undefined

        
    console.log("Get users...");
        xhr = getXmlHttpRequestObject();
        xhr.onreadystatechange = dataCallback;
        // asynchronous requests
        
        const data = xhr.open("GET", "http://localhost:6868/content", true);
        console.log(data);
        }
user20194509
  • 13
  • 1
  • 2
  • The literal answer is `function dataCallback () { if (this.readyState === 4) { const variable = this.responseText; /* now you can use variable while it is in scope */ } }` but the duplicate covers what you probably mean – Quentin Dec 13 '22 at 16:48

0 Answers0