How to import xhr2

I need to import XMLHttpRequest of xhr2 to my code, so I included it in package.json:

“dependencies”: {
“xhr2”: “"
}
“devDependencies”: {
“wrangler”: “2.6.2”,
“xhr2”: "

},

Then my code is:
var XMLHttpRequest = import(‘xhr2’);

this will cause error: ReferenceError: XMLHttpRequest is not defined…

What is the correct way to import it?

Thanks.

Wrangler does not support XMLHttpRequest. You need to use fetch or try with the pollyfill.