Error: ReferenceError: Response is not defined - when running convert2xkt from code
using latest version - 1.1.0
I'm trying to run:
convert2xkt({
WebIFC,
source: options.source,
format: options.format,
metaModelSource: options.metamodel,
output: options.output,
includeTypes: options.include ? options.include.slice(",") : null,
excludeTypes: options.exclude ? options.exclude.slice(",") : null,
rotateX: options.rotatex,
reuseGeometries: (options.disablegeoreuse !== true),
minTileSize: options.mintilesize,
includeTextures: options.textures,
includeNormals: options.normals,
outputXKTModel: (xktModel) => doSomethingElse(xktModel, options.output),
log
}).then(() => {
log(`[convert2xkt] Done.`);
process.exit(0);
}).catch((err) => {
console.error(`Error: ${err}`);
process.exit(1);
});
in order to be able to read the xktModel. but I just keep getting this error: Error: ReferenceError: Response is not defined.
looks like it fails on this function:
function validHTTPResponse(data) {
if (data instanceof Response) {
if (data.status === 204) {
return false;
}
}
return true;
}
I also tried to remove the line I added with the outputXKTModel, but still it doesn't work.
only when I run the script directly from cmd it works, but then I cannot access the xktModel Data
Might take a day or two to patch this one, so if anyone feels adventurous... ;)
A hack could be to create a mock object at initialization to make this useless test not crash.
# Create a mock Response object to fix a Nodejs dependency in loader.gl
window.Response = class Response {};
Hmm weird that you're getting such an error, since (if I understand this issue correctly) convert2xkt.js seems to run OK and basically doing what you're doing, with extra options etc. You should be able to just copy that script as a starting point and modify to your needs...
yes, it is weird , that's exactly what I did and it is still not working, no idea why