Questions tagged [node-fetch]
462 questions
0
votes
1 answer
node js Consecutive API calls not executing
I'm working for a project for a course where I need to chain multiple API calls together. Currently everything in the first API call function executes and shows in the terminal but everything after the first API call doesn't do anything. I'm…

Michael Wycklendt
- 159
- 2
- 11
0
votes
1 answer
Creating form data without using FormData in node-fetch
I'm using node fetch to make API Calls inside a platform.
I need to make an API Call to pass file in form-data.
Below is my stub code:
const fetch = require("node-fetch")
var myHeaders = {"Authorization": "Basic…

Avinash
- 2,003
- 2
- 17
- 15
0
votes
1 answer
request from python get different response from nodejs
I am trying to do the same request from nodejs.
The python code is
import requests
r = requests.post(url,
data=data,
headers={
'User-Agent': self.ua,
…

Abanoub Istfanous
- 856
- 9
- 24
0
votes
0 answers
Node Js function returning undifined variable
My function:
async function GetItemStats(item_id) {
var jsonResponse;
const url = "someUrl";
const data = { data: item_id };
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie:
…
0
votes
2 answers
How to make sure headers that im passing to node-fetch request are correct?
Im trying to rewrite one function which does the get request with request-promise library to be based on node-fetch:
Here is method in request-promise:
import { default as request } from 'request-promise';
async function sendGet(cookies, url) {
…

Piotr Lee
- 3
- 1
- 4
0
votes
1 answer
Cannot Pass Variables Through Different Scopes in DiscordJS
Alright so my problem is that in the first set of console.log(streamXXXX)s, where XXXX are the various variables, when I read their values they all read as they should, while in the second set they read as undefined. Is this a scope issue? Maybe an…

David J
- 49
- 1
- 3
- 11
0
votes
1 answer
Integration testing a fetch calls in a node module
Goal: Call a function that invokes a fetch call to validate it works with my backend rest-api (end to end testing basically).
Project: node module built to be imported into several react web application. The module contains only fetch calls and…

DarkGuardsman
- 126
- 4
- 15
0
votes
1 answer
Could not get image file from API URL in nodejs
const headers = new Headers();
headers.set(
"Authorization",
"Basic " + base64.encode(username + ":" + password)
);
fetch(url, { method: "GET", headers: headers })
.then(res => {
console.log("res", res.statusCode);
…

gopinath
- 61
- 1
- 11
0
votes
1 answer
TypeScript CLI: How to save octect-stream response from node-fetch call to Get Request?
I am making a Get Request using Node-Fetch to a web api. It returns octet-stream response to be saved as a file in a local.
I tried using downloadjs (download()) and download.js (downloadBlob()), but both of them did not work.
downloadBlob()…

Kay
- 1,235
- 2
- 13
- 27
0
votes
2 answers
How to push data from promise to an array
I want to push data from promise to array (coursesArray) and then use the array values else where. I am using node-fetch library to query the API. Currently when i log array inside the promise, it has values(coursesOne) however when i log the array…

freetyy
- 109
- 10
0
votes
1 answer
gatsby-source-graphql does not seem to pass cookie header, how to solve?
How to pass Cookie headers from gatsby-source-graphql?
I'm using the gatsby-source-graphql (https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-graphql) and recently had to implement AWS Cloudfront Signed Cookies to authorise users…

punkbit
- 7,347
- 10
- 55
- 89
0
votes
1 answer
How to prevent duplicate request in chrome with nodejs
As far as I know, the reason why duplication request is occurring in chrome is to get /favicon.ico in the first request and URI in the second request. But as you can see in my simple test code, exactly the same URL is being accessed for both…

Chan Hee Kim
- 9
- 1
0
votes
1 answer
How do I return a reference to a Readable stream before creating it?
I have a function that needs to return a Readable stream synchronously. I have a function that creates a Readable stream with the data I require, but it's an asynchronous method. How can I return a reference to the synchronous stream?
class…

Alexander Craggs
- 7,874
- 4
- 24
- 46
0
votes
2 answers
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 code results in empty body -
function makeRequest…

Boudhayan Dev
- 970
- 4
- 14
- 42
0
votes
1 answer
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 supposed to check the response for a status code…

Chrillewoodz
- 27,055
- 21
- 92
- 175