How to send cookies with node-fetch?
You should be able to pass along cookies by setting it in the header of your request: const opts = { headers: { cookie: ‘accessToken=1234abc; userId=1234’ } }; const result = await fetch(`/some/url`, opts);
You should be able to pass along cookies by setting it in the header of your request: const opts = { headers: { cookie: ‘accessToken=1234abc; userId=1234’ } }; const result = await fetch(`/some/url`, opts);
The node-fetch latest version doesn’t use the require() syntax to import the package. You need to go to your package.json and type { “type”: “module”, } to use the import syntax and import node-fetch, but then you can’t use require for any other packages. You need to work with import statement only. Or you can … Read more
From the Upgrade Guide node-fetch was converted to be a ESM only package in version 3.0.0-beta.10. node-fetch is an ESM-only module – you are not able to import it with require. Alternatively, you can use the async import() function from CommonJS to load node-fetch asynchronously: // mod.cjs const fetch = (…args) => import(‘node-fetch’).then(({default: fetch}) => … Read more