Questions tagged [node-fetch]
462 questions
0
votes
0 answers
POST Works with linux curl but 403 Forbidden with node-fetch and windows curl UGGGG
THIS REQUEST WORKS AND RETURNS {"projectId":"508980180","userFavorite":true,"statusChanged":true}:
curl 'https://api.scratch.mit.edu/proxy/projects/508980180/favorites/user/iIhp1O' \
-X 'POST' \
-H 'authority: api.scratch.mit.edu' \
-H…
0
votes
0 answers
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 this code.
let tokenToBeUsedLater: string;
//…

HigoChumbo
- 858
- 2
- 9
- 23
0
votes
1 answer
TypeScript: type for returning an async function call inside a setTimeout()?
I have a function for fetching credentials for an external API (oversimplified):
const fetchCredentials= async () => {
return await fetch(/* url and params */);
};
And another one which calls the above and keeps retrying to call if it the…

HigoChumbo
- 858
- 2
- 9
- 23
0
votes
2 answers
Javascript: read from url in unicode-escape format
I am using node-fetch to read data from URL. The return result is perfect except it is different from my preferred result.
For some special characters like í or this ř, I want it instead to be in the format as following: u00ed and u0159.
Is it…

Jane
- 151
- 3
- 12
0
votes
1 answer
node-fetch and Google Analytics Measurement Protocol
Trying to collect stats using the GAMP for nodejs. When I test the debug for issues I constantly get: A value is required for parameter 'v'. Why does this not work?
async function gaCollect(){
var url =…

deadpickle
- 115
- 2
- 15
0
votes
0 answers
File Upload Using node-fetch Socket Hang Up After Second Try
I'm currently trying to upload a file to AWS S3 using node-fetch in Node.js. On the first try, the operation is successfully done. But on the second try, the socket hangs up. The error is:
Error: FetchError: request to…

Dominique Altrez
- 113
- 9
0
votes
1 answer
Unable to parse Response message using node-fetch
My goal is to read the message that is returned within the response. I am using node-fetch and the response is gzipped. This is what I have so far:
const response = await fetch(config.url, {
method: 'POST',
body: request,
…

Ahmed
- 121
- 6
- 18
0
votes
1 answer
Looping through a fetch operation in Node JS
I'm trying to write a collection of Json objects into an array whilst looping through a fetch operation in Node JS. I'm sure the issue is something to do with it being an Async operation, but can't figure out how to get round it.
This is my code:
…

Strontium_99
- 1,771
- 6
- 31
- 52
0
votes
1 answer
Correct AXIOS version of node-fetch POST
I use axios in a pet project and have a code sample from the BambooHR API (https://documentation.bamboohr.com/reference#request-custom-report-1). They use node-fetch, so I was rewriting it to axios. The sample code is:
const fetch =…

Martin Schlott
- 4,369
- 3
- 25
- 49
0
votes
2 answers
JS node-fetch can't get data from a fetch promise
I want to fetch data from the wikipedia api via node-fetch.
Unfortunately I don't manage to set a variable outside my fetch-Promise-Chain. I wanted to pass this variable on to render page to fill in a form. If I consle.log the inside the fetch()…
0
votes
1 answer
Callback function 'next' is executed automatically without making a call to it
I have this POST method which uses FetchURL middleware to fetch data from the url submitted by the user.
router.post('/', FetchURL, (req, res) => {
console.info('data received');
...
})
Everything works with response.ok being true, but the…

Sapinder Singh
- 559
- 6
- 21
0
votes
4 answers
Fetch API not giving response data in Node.js
I have been trying to fix this but it gives me this: ReferenceError: json is not defined
this is my code:
const fetch = require('node-fetch');
function makeAFile(text){
fetch("http://bin.shortbin.eu:8080/documents", {
method: "post",
…

OpenSaned
- 105
- 1
- 1
- 8
0
votes
1 answer
My Discord bot sends messages in a weird way
I'm currently working on a Discord bot that tracks Steam prices and sends them to chat. I made this code for it:
setInterval(() => {
const currentDate = new Date();
var yourchannel = client.channels.cache.get('[CHANNEL ID]');
…

Brunon
- 31
- 2
0
votes
1 answer
Why is TypeScript accepting an URL in node-fetch
In TypeScript I can do the following:
const fetchUrl = async () => {
let url: URL = new URL("http://example.com")
url.searchParams.set("q", "hello")
url.searchParams.set("a", "world!")
return fetch(url)
}
And I want to know why this is…

froehli
- 904
- 1
- 11
- 35
0
votes
1 answer
How to get specific cookie from Node-Fetch
Is it possible to get a specific cookie from set-cookie in node fetch.js
var ResonseCookies = (SentRequest.headers.raw()['set-cookie']);
and it has returned me as i wanted
[
'language=en; expires=Tue, 23-Feb-2021 00:55:18 GMT; Max-Age=2592000;…

Jamie Schofield
- 11
- 6