Converting XML to javascript Document

Hello!
I’m trying to parse the page content xml response from /wiki/api/v2/pages/${contentId} into a javascript Dom Document. I’ve tried JSDOM and DOMParser:

        const contentId = context.contentId();
        const page = await asUser().requestConfluence(route`/wiki/api/v2/pages/${contentId}`, {
            headers: {
                'Accept': 'application/json'
            }
        });
        const responseJson = await page.json();
        const xml = responseJson.body.storage.value;
        const parser = new DOMParser();
        const xmlDoc = parser.parseFromString(xml);

but I get this error:

Error: Error thrown in the snapshot context.
App code snapshot error: Snapshot error occurred: Error: window is not defined
Learn more about the snapshot context at https://go.atlassian.com/forge-snapshot-context.
    at ArtifactDeployer.handleErrorEvent (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/deploy/deployer/deployer.js:147:23)
    at ArtifactDeployer.pollAndCheckEvents (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/deploy/deployer/deployer.js:81:18)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ArtifactDeployer.monitorDeployment (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/deploy/deployer/deployer.js:92:28)
    at async ArtifactDeployer.deploy (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/deploy/deployer/deployer.js:56:9)
    at async PackageUploadDeployCommand.execute (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/deploy/package-upload-deploy.js:23:9)
    at async CommandLineUI.displayProgress (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/node_modules/@forge/cli-shared/out/ui/command-line-ui.js:46:28)
    at async DeployView.reportDeploymentProgress (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/command-line/view/deploy-view.js:79:24)
    at async DeployController.run (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/command-line/controller/deploy-controller.js:172:27)
    at async Command.actionProcessor (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/command-line/command.js:91:32)
    at async Promise.all (index 0)
    at async Command.parse (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/command-line/command.js:194:13)
    at async main (/Users/roryarmstrong/.nodenv/versions/16.16.0/lib/node_modules/@forge/cli/out/command-line/index.js:59:5)

I’m looking to convert this document into Markdown for use integrating with Github but this is blocking further development. I understand that there’s limitations on forge, but is there any libraries that forge allows or provides to enable this functionality?

My version of forge is:

    "@forge/api": "2.11.1",
    "@forge/ui": "1.9.0",

Nevermind - turns out it was the turndown dependency that was causing issues: turndown - npm