Questions tagged [node-fetch]
462 questions
1
vote
0 answers
Getting "socket hang up at ClientRequest." when calling GET request using node-fetch
I am using node-fetch modeule along with javascript to work with API requests. Below is my code (just a sample GET operation)
var fetch = require('node-fetch');
const HttpsProxyAgent = require('https-proxy-agent');
…

johny
- 51
- 1
- 11
1
vote
1 answer
Convert a cURL command with the GET and data-urlencode options to javascript using node-fetch
I am developing a web app using node.js and express.js.
Here is the working cURL command that I would like to convert to javascript using the node-fetch module.
curl -X GET -H "X-Parse-Application-Id: APPLICATION_ID" -H "X-Parse-REST-API-Key:…

alextc
- 3,206
- 10
- 63
- 107
1
vote
1 answer
How do I stub a module with Jest and Proxyquire?
I want to force node-fetch to be a stub and I'm having a bit of trouble
getting it to work. Code:
const fetchMock = jest.fn();
const {
getArticle
} = require('../../sfpublish/api');
console.log('loaded api')
const A =…

jcollum
- 43,623
- 55
- 191
- 321
1
vote
1 answer
multiple calls from for loop to array, then drop 0 length results
This is what I am trying to achieve, I am making one call to an api that results in multiple calls based on zip code and radius. Based on population density results could be as few as one result or as many as twenty. The results of this call are…

Chuck LaPress
- 278
- 1
- 10
- 18
1
vote
1 answer
How can I implement nested node-fetch calls?
For example, I want to retrieve some data from an API (a User) so I can retrieve more data (a Team associated with that User). Something like:
var fetch = require('node-fetch');
app.get('/users/:username', function (req, res) {
var username…

Roderick
- 2,383
- 3
- 20
- 33
1
vote
1 answer
tslint: Forbidden http url in string
function getStuff(req: express.Request, res: express.Response, next: express.NextFunction): void {
fetch('http://localhost:3000/stuff')
.then((data: {}) => {
res.send(data.body._readableState.buffer.head.data.toString());
…

Attila
- 1,097
- 2
- 19
- 45
1
vote
1 answer
Node-fetch returns Promise { } instead of desired data
I am currently trying to fetch JSON from a website using the node-fetch module, and have made the following function:
var fetch = require("node-fetch");
function getJSON(URL) {
return fetch(URL)
.then(function(res) {
return res.json();
…

LegusX
- 37
- 1
- 3
- 7
0
votes
0 answers
When I introduced node-fetch in my codebase I get 'import_node_fs.promises' as it is undefined
I am working on a Vite project with React and I am trying to make a request with node-fetch. I have installed the dependency as described in the docs but I am getting this logs on browser console.(Test it on chrome and edge and the give me the same…

Legionas
- 31
- 5
0
votes
0 answers
Node.js fetch certificate expired
(node:25) UnhandledPromiseRejectionWarning: FetchError: request to
https://*******************?grant_type=client_credentials&client_id=****************&client_secret=******************&scope=api
failed, reason: certificate has expired
at…

Kushagra Agarwal
- 1
- 1
0
votes
1 answer
Mocking method response with Jest spies and spying on node-fetch arguments
I have one object (ConvertkitServer) that contains two methods: addSubscriberTags() that calls getConvertkitTags(). Both use fetch() and the scope of this question is limited to the tests I’m creating for addSubscriberTags():
import fetch, {…

Andrew Connell
- 4,939
- 5
- 30
- 42
0
votes
1 answer
request to https://api-m.sandbox.paypal.com/v1/oauth2/token failed, reason: unable to get local issuer certificate, nodejs, cPanel
I'm creating a nodejs app with paypal buttons.
The app works on local computer just fine, but I have problems with integrating it with cPanel. The application works as a server behind the passenger reverse port binding and tries to fetch data from…

jus
- 1
- 2
0
votes
0 answers
uploading using form-data a remote file
in my node application I want to use FormData to upload a remote image.
To do this I'm trying the following
const form = new FormData();
...
const result = await fetch(image);
form.append("file", result.body);
...
This is generating the…

fabpicca
- 285
- 1
- 3
- 16
0
votes
3 answers
Inspecting outgoing HTTP requests in a nodejs application
I am using NestJS to build a web app from which I call an external API to retrieve data. Now, I want to inspect all the requests that are sent from my app. For example, in a web browser, I can inspect all the requests I send to my server through the…

boumour ilyass
- 1
- 2
0
votes
0 answers
How to get redirected query parameters into nodejs?
I am working on an app to track our outbound UPS packages using the UPS API. For those that do not know, they are implementing a OAuth token system to authenticate requests. This article shows the flow of the process:…

matthh
- 47
- 4
0
votes
0 answers
Scraping Table on Site and adding to Parse
I'm going through trying to create an app that will populate a database over time with information from our website. I'm doing this with Cloud Code on a Parse server over at back4app.com. I have the following code set up, and the problem is it won't…

user717452
- 33
- 14
- 73
- 149