0

I am new to jscript. I am simply trying to connect to my api (which works on postman):

async function sendMSG() {
  var username = "username";
  var password = "xxx";
  var url = "https://api.kumulos.com/b2.2/xxx/getAllUsers.json";
  const request = new XMLHttpRequest();
  request.open('GET', url, false, username,password)
  await request.send()
}

but upon the line "send()", firefox gives me:

Uncaught (in promise) DOMException: A network error occurred.

Can you help me?

Thank you

Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
JuTo
  • 25
  • 4
  • 2
    Avoid using `XMLHttpRequest`. Use the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) instead. Especially if you are requesting JSON data. – Mr. Polywhirl Jun 07 '21 at 14:38
  • 1
    Otherwise, XHR is not a Promise. You can wrap it if you really want to, but if you are in a browser supporting `async`-`await`, you can presumably use `fetch()` – tevemadar Jun 07 '21 at 14:38

0 Answers0