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

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

Closed
kasir-barati opened this issue Feb 28, 2025 · 2 comments

Comments

@kasir-barati
Copy link

Describe the bug

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:

{
  "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:

{
  "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

N/A.

Reproduction URL

No response

Version

7.8.1

Environment

Linux, Ubuntu

Additional context

No response

@kwonoj
Copy link
Member

kwonoj commented Feb 28, 2025

Rxjs does not provide or polyfills global for the environment does not have it. It's up to user's config to porvide necessary polyfill.

@kwonoj kwonoj closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2025
@kasir-barati
Copy link
Author

Either please confirm if this is a bug (which I doubt), or add some sort of docs in your website please

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