Questions tagged [node-fetch]

462 questions
0
votes
0 answers

node-scheduler to send response from node REST API

I am working with node REST API. I need to send 2 different responses from single API. So I am sending first response from API as res.send(). Then I am using node-schedule to send remaining 1 response after some time using node-fetch. But failing…
0
votes
1 answer

cant get ES modules to work with import or require

I'm building a command line based application and was using require to link various files and node modules. I have previously used Require with no issues and now I get nothing but errors. Error with Require: Error [ERR_REQUIRE_ESM]: require() of ES…
dhuw
  • 9
  • 3
0
votes
1 answer

Use Node-Fetch in TypeScript with CloudFunctions

So Im using Cloud Functions from Firebase with TypeScript I want to import node-fetch like: import * as fetch from "node-fetch"; but it doesn't import correctly: when I try to use fetch like this: …
Nikita
  • 477
  • 4
  • 14
0
votes
0 answers

Extend node-fetch default timeout

I am using node-fetch to perform a get request const fetch = require("node-fetch"); try { const response = await fetch( `https://someurl/?id=${id}` ); } catch (error) { console.error(error); } The API take long…
user567
  • 3,712
  • 9
  • 47
  • 80
0
votes
1 answer

node-fetch even though server is online it keeps saying errconrefused

Connecting to the server through browser is possible and i get http code 200, I have directly copied the url from the browser to the node fetch: await…
drk1
  • 65
  • 11
0
votes
0 answers

API works in browser but not when pulled from Node

Here is my code: import fetch from "node-fetch"; class BlueNileAPI { constructor() { } fetchDiamonds() { return…
boioboi
  • 45
  • 7
0
votes
0 answers

I am getting a response code of 400 or 429

I am working on REST API. From my end, everything seems to be fine. I've tried multiple libraries (AXIOS, request, fetch) in order to make a PUT call. However, I keep on getting 429 or 400 as a response code. Below is the implemented code const…
RAJENDRA H
  • 83
  • 10
0
votes
1 answer

Why does my Node Express, node-fetch API seem to work on the server side, but it falls apart on the client side?

There are other questions related to this one, but none are specific to this particular issue. None that I could find. None of them ask the following question: "Why does my server-side node-fetch API work in Node Express, but it immediately falls…
0
votes
0 answers

Send cookies with node-fetch to bing

I am trying to fetch bing search results with 50 searches per page. Simply editing the url to include "&count=50" doesn't work, and so I am sending a cookie to update the preference. Right now I have: const opts = { headers: { cookie:…
guy
  • 1
  • 1
0
votes
1 answer

Typscript cannot import node-fetch

I'm trying to import 'node-fetch'. import fetch from "node-fetch"; But I seem to get an error. C:\Users\pat\Documents\GitHub\js\flux\backend\dist\http.js:7 const node_fetch_1 = __importDefault(require("node-fetch")); …
HippoBaguette
  • 308
  • 4
  • 15
0
votes
1 answer

Node-Fetch unhandled promise rejection (can't catch it)

I'm struggling for 2 days on this one so I try asking here: I have a nodejs script using node-fetch to make queries ton an API. However, I've tried adding catch blocks everywhere but it seems I didn't suceeded in ahndling the error. Here is my…
Kashnars
  • 3
  • 3
0
votes
2 answers

Trying to install node-fetch but it results in an error

I started to mess around with discord bots and I would need node-fetch for the tutorial which I started learning from. I'm simply trying to run: (to install node-fetch) npm install node-fetch Which results in an error seen below. This is the actual…
Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222
0
votes
2 answers

How to get a certain element from a body?

I use node-fetch , and I get the body of the site this way: import fetch from 'node-fetch'; (async () => { const response = await fetch('link'); const body = await response.text(). console.log(body); })() The console displays the full…
John
  • 33
  • 7
0
votes
0 answers

Accessing data from a REST API works with cURL but not fetch in node

I am trying to get data from a udemy API. I can get it with cURL in the console but not with fetch. Please can anyone look at my code and let me know what I am doing wrong? const fetch = require("node-fetch"); const express =…
Develop96
  • 1
  • 3
0
votes
1 answer

TypeScript issue with node-fetch and trying to omit some properties from RequestInit

I'm quite new to TypeScript I'm trying to write a wrapper around making a post request that looks like import fetch from 'node-fetch'; async function post( address: string, url: string, body: any, headers?: Record, …