Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
218 views

send very big data to an api in parallel and catching errors within promise.allSettled

I have quite big data, to be sent to an api with node-fetch. But, since there are many data in the array, and I want to send the data in parallel, I wanted to use promise.allSettled... Yet, it still ...
m-alptekin's user avatar
0 votes
2 answers
112 views

Async function returns promise after .then

In my code, I have an async function that returns a promise.I am aware that this question has been asked before, however none of the solutions worked. const fetch = require('node-fetch'); async ...
Arjinoodles's user avatar
0 votes
1 answer
341 views

Concat json to promise: How to get additional key value pair in json object from promise pending

I manually concat a json object to a promise. The code below on the first print, cosole.log(new_response) gets me this, which is what I want Promise { <pending>, a: '123' } However the second ...
Sun Tianyi's user avatar
-1 votes
1 answer
50 views

Promise in Node.js for storing and using a JSON inside the code [duplicate]

I have a code that takes the JSON of a webpage (from a link) and prints it into the console with a promise, using node-fetch (npm node-fetch) and .then I need to get the content of this specific ...
noxter's user avatar
  • 202
-1 votes
1 answer
58 views

Problem regarding the node-fetch api. Specifically, when attempting to use fetch to retrieve JSON data

Code below retrieves the JSON data without any problems. app.get('/startgame', (req, res) => { res.send('Welcome To The Start Of The Game') fetch("https://deckofcardsapi.com/api/...
James Le-Goff's user avatar
0 votes
0 answers
408 views

TypeScript: how to handle async functions inside setTimeout()?

I have the following timed function to periodically refetch credentials from an external API in your usual movie fetching IMDB clone app: // This variable I pass later to Apollo Server, below all ...
 HigoChumbo 's user avatar
-2 votes
2 answers
49 views

How to pass data between promise asynchronously?

I want to fetch from the backend several data and process them at the end when they're loaded. Right now, when this code runs, data1 and data2 are undefined. I want to wait for them but I don't know ...
Olivier D'Ancona's user avatar
0 votes
1 answer
134 views

Google Cloud Functions req/res with Promise by node-fetch

I am a total newbie to Javascript and trying to set up a bridge between two of the services I use. The goal is simply take body or the request, do a promise api call to another service to respond with ...
Yuri Vaskovski's user avatar
-1 votes
2 answers
7k views

Node-Fetch API | What is text() stand for? (Promise issue) [closed]

can anyone tell me exactly what text() do? I see people using it like that, and its working indeed: async getRandomNumber() { return await fetch(`${this.url}random`) .then((...
Darmon's user avatar
  • 303
6 votes
1 answer
6k views

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 (...
HerrZatacke's user avatar
0 votes
2 answers
1k views

How to resolve nested promise in NodeJs?

I am making using of node-fetch module to make API calls. I have a function that makes all the API calls. And from this function I am returning the status code and the response body. The following ...
Boudhayan Dev's user avatar
0 votes
1 answer
76 views

Catch callback runs instead of then callback when making a http request from one server to another

I'm using node-fetch to make a call from one API to another one, however when an error occurs in "API 2", the success callback runs. I'm not sure if this is intended behaviour or not and if you're ...
Chrillewoodz's user avatar
  • 28.3k
2 votes
0 answers
2k views

returning a value from node-fetch [duplicate]

exports.img = function(){ fetch("http://aws.random.cat/meow") .then(res => res.json()) .then(json => console.log(json.file)); } I have been trying to return the "file" value from the json ...
Conner Ray Copeland's user avatar
0 votes
2 answers
577 views

Azure Function automatic retry on failure UnhandledPromiseRejectionWarning

const fetch = require('node-fetch'); let url = 'something.com'; module.exports = function(context) { let a = fetch(url) a.then(res => { if(res.status!=200) throw new Error(res.statusText) ...
Nafis Islam's user avatar
  • 1,509
0 votes
2 answers
581 views

How to define a function which returns Promise to a Express Route function?

I have a business leve database module called "db_location" which uses the node-fetch module to get some data from a remote server via REST API. **db_location.js** DB LOGIC const p_conf = require('.....
alextc's user avatar
  • 3,515
2 votes
4 answers
2k views

How to deal with returned object on Error in a Promise-based business-level function in Node.js?

I need to create a business level function called "getLocationById" which retrieves some data from a remote server via REST API. This function is then called by a router to display the data on a web ...
alextc's user avatar
  • 3,515
0 votes
2 answers
1k views

incorrect behaviour of node-fetch while trying to get token from an api

I want to connect to an external api using some node-fetch code. My code first sends the login details & should receive a token from the api. Then this token is used for all the later ...
Kapil Gupta's user avatar
  • 7,671
2 votes
1 answer
13k views

dealing with an array of objects with promises

I am trying to make a node express app where I fetch data from different url's making a call to node-fetch to pull the body of some pages and other information about certain url endpoints. I want to ...
petermas's user avatar