Skip to content

XMLHttpRequest is not defined (Should Import xhr2) #101

@tkt9k2562

Description

@tkt9k2562

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions