Questions tagged [node-fetch]
462 questions
0
votes
0 answers
My firebase cloud function to fetch URLs results in robot detections
i'm trying to make a simple GET request to external URLs from my cloud function using node-fetch. When a user pastes a link, I'm making this request to retrieve social media sharing tags to populate title, description and image. Some websites seem…

SupRob
- 11
- 2
0
votes
1 answer
How does rails v6 fills REQUEST's content-length when a client doesn't send content-length in the headers?
Long story short, I am using node-fetch to upload a file to a Rails server.
The file is from fs.createReadStream = ReadStream.
https://github.com/node-fetch/node-fetch
Note: when body is a Stream, Content-Length is not set automatically.
As it…

kukrt
- 2,117
- 3
- 21
- 32
0
votes
0 answers
Module import or export statement unexpected here Javascript
I am trying to use node fetch to retrieve a string from a Misty robot and then pass this information to a Lobe ML model for a senior year developmental class.
The problem is that fetch was originally not defined. I then installed the package in the…
0
votes
0 answers
Js: Can't import object from external file with node-fetch imported
I have some credential saved in a file called secrets.js, in the same folder of the main.js file.
In the secrets.js file I wrote this:
const secrets = {}
secrets.key = "..."
secrets.discord = "..."
secrets.cityName = "..."
module.exports =…
0
votes
1 answer
How to make three POST requests using node-fetch
I am making POST requests to an API and I want to make three requests as efficient and with less code as possible. Currently my code works, but it sends only the first object, instead of all three, what is the most efficient way to make three API…

codePanda
- 21
- 2
0
votes
1 answer
node-fetch ignores query string with commander.js
I created a CLI with commander.js that I have published via npm. The CLI uses node-fetch to request data from an API. However, for some users of my CLI, node-fetch is ignoring the query string in my fetch URL.
My assumption is that the some users…

dcporter7
- 535
- 3
- 14
0
votes
1 answer
Why is node fetch not working (node-fetch) in javascript
I'm trying to fetch data from a URL with fetch but it doesn't work. I imported node-fetch module by typing:
const fetch = require("node-fetch");
And here's where I use it:
async function getUrl(url) {
let d = await fetch(url);
let j =…

Efe FRK
- 177
- 1
- 13
0
votes
2 answers
Is it possible to set the value of promise to a object
So I have used .then to try and assign the value of promise to the object but I can't and now I tried a anonymous async function which isnt helping me.
import fetch from 'node-fetch'
import { setProps } from '../helpers/objectResponse.js';
if…

haideralidev
- 63
- 6
0
votes
0 answers
How to update project when a dependency switches to pure ESM
We are developing a project that uses commonjs. When node-fetch is updated to v3.x, jest complains that:
import fetch, { RequestInfo, RequestInit, Response } from 'node-fetch';
SyntaxError: Cannot use import statement outside a module
npm run…

Alireza
- 5,421
- 5
- 34
- 67
0
votes
1 answer
Check if no data returned node-fetch discord.js
So I'm trying to make a command for my bot that converts Minecraft usernames into uuid, the mojang API returns NO data when the username is not recognized, is there a way to check if no data was returned without my bot…

dmcpacks
- 7
- 2
0
votes
2 answers
Why won't this fetch error handling work?
I have a Discord bot using discord.js. Since I implemented slash commands, if the server is down when fetching files from it, it'll make my bot crash. I've tried a number of things but I can't seem for the life of me to figure out how to catch the…

Cascavel
- 305
- 1
- 3
- 9
0
votes
1 answer
node-fetch "api key is not a legal HTTP header" error
I am attempting to do a GET request to an external API using node-fetch. When I run the code, I get the below error:
UnhandledPromiseRejectionWarning: TypeError: Bearer [api key] is not a legal HTTP header value
The Bearer key is in JWT format and…

Shawn Stensberg
- 3
- 2
- 3
0
votes
0 answers
Discord oAuth2: How do I get the authentification header working
What I am trying/wanting it to do: I am trying to make it log the info of a user after authorization
What happens: It says { message: '401: Unauthorized', code: 0 } whenever I fetch the users info, even though I put the authorization headers
The…

FireyJS
- 61
- 1
- 11
0
votes
1 answer
JSON error in NodeJS Node-Fetch Call Stripe
For Some Reason, I am getting this error when using stripe API in node-fetch.
Error: TypeError: Cannot use 'in' operator to search for 'signal' in
{"method":"post","headers":{"Content-Type":"application/json","Authorization":"Bearer API…

DIllon marks
- 59
- 1
- 6
0
votes
1 answer
Fail to parse on a json stream using node-fetch
I run the sample code from node-fetch stream feature.
Sometime it can successfully parse the chunk, sometimes return error msg SyntaxError: Unexpected token { in JSON at position 312
const fetch = require('node-fetch');
async function main() {
…

icelemon
- 827
- 2
- 11
- 23