Questions tagged [node-fetch]
462 questions
7
votes
1 answer
Axios and fetch responded with different status code from same external endpoint
I'm trying to send a request to this endpoint: https://9gag.com/v1/group-posts/group/default/type/trending to get 9gag posts data.
Works fine on postman and chrome, but when I tried using axios from Node.js, it responded with 403 (and reading the…

Owl
- 6,337
- 3
- 16
- 30
7
votes
3 answers
Retrieving OAuth2 Token Via Node-Fetch
The issue is that I'm trying to retrieve a OAuth2 token. Since request has been deprecated, I'm using node-fetch for this. While I can get it to work with request, I cannot with node-fetch.
I have read numerous posts here about but none seem to…

Jeff Nyman
- 870
- 2
- 12
- 31
7
votes
1 answer
trouble using node.js w/ node-fetch module in async AWS Lambda Function
Here's what I'm trying to do: I have a lambda function triggered by a webhook that will process that data and use it to make a POST request to an api.
I'm using Node.js 12 and the node-fetch module.
Right now the function is being triggered…

benjfriedrich
- 75
- 1
- 1
- 6
7
votes
4 answers
Discord Oauth2 Join Guild
const guildMembersResponse = fetch(`http://discordapp.com/api/guilds/440494010595803136/members/278628366213709824`,
{
method: 'PUT',
headers: {
Authorization: `Bearer TOKEN`,
},
…

G33RY
- 141
- 1
- 2
- 10
6
votes
2 answers
'body used already for' error when mocking node fetch?
I'm trying to mock node-fetch with jest for my azure functions. In the test I have the following:
index.test.ts
jest.mock("node-fetch");
import fetch from "node-fetch";
const {Response} = jest.requireActual("node-fetch");
// Setup code…

avenmia
- 2,015
- 4
- 25
- 49
6
votes
2 answers
How to know the url that I will be redirected to? [nodejs] [node-fetch]
I am trying to load a JSON file from a url in google cloud. I am using the node-fetch package and it works fine for a couple of hours. The problem is that google changes the redirected url frequently. How can I make a get request to the url I will…

ce-loco
- 262
- 4
- 10
6
votes
4 answers
Reuse TCP connection with node-fetch in node.js
I am using this function to call an external API
const fetch = require('node-fetch');
fetchdata= async function (result = {}) {
var start_time = new Date().getTime();
let response = await fetch('{API endpoint}', {
method: 'post',
…

Ofer B
- 369
- 2
- 5
- 14
6
votes
1 answer
How to fix Typescript compilation error ts2345 "Type 'Response' is missing ... from type 'Response': redirected, trailer, formData!"
I am trying to make a request using node-fetch in my typescript project and I do not understand how to fix the compilation error or what it actually tries to tell me.
I've updated all packages (including the global typescript package) to the latest…

HerrZatacke
- 273
- 2
- 10
6
votes
1 answer
node-fetch connect ETIMEDOUT error
I am trying to get 200 status code in response, but as a result it's ETIMEDOUT.
I can't understand, how is it possible that I can grab successful response via postman, but same via node-fetch responding with ETIMEDOUT always.
Here is an example of…

blindeveloper
- 101
- 1
- 1
- 5
6
votes
1 answer
Proper way to consume NodeJS stream into buffer and write stream
I have a need to pipe a readable stream into both a buffer (to be converted into a string) and a file. The stream is coming from node-fetch.
NodeJS streams have two states: paused and flowing. From what I understand, as soon as a 'data' listener is…

andykais
- 996
- 2
- 10
- 27
5
votes
2 answers
node-fetch@3 Not support in nestjs because it is ESM
I can't use the package "node-fetch@3". I just import it and my console will log the error:
const node_fetch_1 = require("node-fetch");
^
Error [ERR_REQUIRE_ESM]: require() of ES Module…

pu nanjo
- 51
- 1
- 2
5
votes
3 answers
node-fetch: Unsupported URL Type "node:": node:buffer
I need to get node-fetch working for a VUE JS project but I ran into these dependencies errors:
These dependencies were not found:
* node:buffer in ./node_modules/node-fetch/src/index.js, ./node_modules/node-fetch/src/body.js
* node:http in…

Tom
- 5,588
- 20
- 77
- 129
5
votes
2 answers
const fetch = require("node-fetch"); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module
I have a problem, I know nothing about programming and I want to make an nft collection, I am following this youtube video: https://www.youtube.com/watch?v=AaCgydeMu64
everything went fine until around (32:14)
My text is identical to the one in the…

BloomstY
- 51
- 1
- 2
5
votes
2 answers
node-fetch send post body as form-data
I am trying to send a POST request with body as form-data since this seems to be the only way that works.
I tried this in Postman too and sending body as raw JSON didn't work.
So I tried doing the same with node-fetch but seems like body is being…

Azima
- 3,835
- 15
- 49
- 95
5
votes
1 answer
Only HTTP(S) protocols are supported in apollo gateway
I am trying to run apollo gateway locally using the managed configuration from apollo's managed solution. It loads the schema and everything is fine but when I try a query in the playground I get 'Only HTTP(S) protocols are supported'. I know I can…

Niall
- 804
- 10
- 27