Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLHttpRequest is not defined (Should Import xhr2) #101

Open
tkt9k2562 opened this issue Dec 23, 2024 · 2 comments
Open

XMLHttpRequest is not defined (Should Import xhr2) #101

tkt9k2562 opened this issue Dec 23, 2024 · 2 comments

Comments

@tkt9k2562
Copy link

I can found the error on localhost when I try to retrieve instance

My code is

const client = new DICOMwebClient.api.DICOMwebClient({
    url: process.env.DICOM_WEB_API,
    debug: true
});

const arrayBuffer = await client.retrieveInstance({
    // replace the UID
    studyInstanceUID: "xxx",
    seriesInstanceUID: "yyy",
    sopInstanceUID: "zzz"
});

The erros is

ReferenceError: XMLHttpRequest is not defined
    at XXX/node_modules/dicomweb-client/build/dicomweb-client.js:501:65
    at new Promise (<anonymous>)
    at DICOMwebClient._httpRequest (/Users/tangguoting/tmu/shh-pacs/koa/node_modules/dicomweb-client/build/dicomweb-client.js:500:16)
    at DICOMwebClient._httpGet (/Users/tangguoting/tmu/shh-pacs/koa/node_modules/dicomweb-client/build/dicomweb-client.js:619:21)
    at DICOMwebClient._httpGetMultipartApplicationDicom (/Users/tangguoting/tmu/shh-pacs/koa/node_modules/dicomweb-client/build/dicomweb-client.js:908:21)
    at DICOMwebClient.retrieveInstance (/Users/tangguoting/tmu/shh-pacs/koa/node_modules/dicomweb-client/build/dicomweb-client.js:1530:23)
    at /Users/tangguoting/tmu/shh-pacs/koa/app.js:51:42
    at dispatch (/Users/tangguoting/tmu/shh-pacs/koa/node_modules/koa-compose/index.js:42:32)
    at /Users/tangguoting/tmu/shh-pacs/koa/node_modules/koa-router/lib/router.js:261:18
    at dispatch (/Users/tangguoting/tmu/shh-pacs/koa/node_modules/koa-compose/index.js:42:32)

And I found that it could be solved by modifing the node_modules/dicomweb-client/build/dicomweb-client.js ,
with adding const XMLHttpRequest = require('xhr2').XMLHttpRequest; in first line.

Version:

  • "dicomweb-client": "0.10.4"
  • "xhr2": "^0.2.1"
@pieper
Copy link
Contributor

pieper commented Dec 23, 2024

This makes sense - I don't think people have used this lib in node, but making it compatible would be great. Do you think you could make a PR and also add a test or tests for it?

@tkt9k2562
Copy link
Author

Let me try it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants