Visitar URL original
fetch is not a function · Issue #1851 · node-fetch/node-fetch · GitHub
Skip to content

fetch is not a function #1851

Open
Open

Description

@cmdparkour

when i install node-fetch and using const fetch = require('node-fetch');
but when i using the fetch, it's wrong, and the message is fetch is not a function

Reproduction

Steps to reproduce the behavior:
const nodefetch = require('node-fetch');
const siteInfoRes = await nodefetch(fetchUrl, {
method: 'GET',
headers: {
'Authorization': Bearer ${TOKEN}
},
params: {
siteId: SITE_ID,
}
});

Expected behavior

Screenshots

Your Environment

software version
node-fetch 3.3.2
node 22.16.0
npm usnig pnpm the last version
Operating System

Additional context

Activity

  1. YasharF commented on Oct 21, 2025

    @YasharF

    Migrate to Node.js's built in fetch: https://nodejs.org/docs/v22.21.0/api/globals.html#fetch

  2. Naeem313786 commented on Feb 14, 2026

    @Naeem313786

    nor working for me as well same issue

  3. YasharF commented on Feb 14, 2026

    @YasharF

    Delete all of it, uninstall node-fetch, and then go to the above link I provided to see how you are supposed to use Node.js's built-in fetch.

    Most likely you should end up with something similar to this:
    https://github.com/sahat/hackathon-starter/blob/bb265d154d5a90f199a6c3df498ddfd15340cb84/controllers/api.js#L595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions