ITADN

In NodeJS I get `ReferenceError: XMLHttpRequest is not defined` when using "rxjs/ajax"

#7535Closedkasir-barati 创建于 2025-02-28
K
kasir-baraticommented
### Describe the bug ```ts import { ajax } from 'rxjs/ajax'; const observable$ = ajax.get('https://reqres.in/api/users/2'); observable$.subscribe({ next(data) { console.log(data); }, complete() { console.info("And we're done, we've fetched all data we could!"); }, error(err) { console.error(err); }, }); ``` A simple TS snippet with this `tsconfig.json`: ```json { "compilerOptions": { "module": "NodeNext", "declaration": true, "strict": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "ES2024", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "allowSyntheticDefaultImports": true, "incremental": false, "skipLibCheck": true }, "exclude": ["node_modules", "dist"] } ``` And this `pacakge.json`: ```json { "name": "rxjs", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "ts-node" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "rxjs": "^7.8.1", "ts-node": "^10.9.2" } } ``` ### Expected behavior Just work ### Reproduction code ```typescript N/A. ``` ### Reproduction URL _No response_ ### Version 7.8.1 ### Environment Linux, Ubuntu ### Additional context _No response_
关闭于 2025-02-28 2 条评论