Questions tagged [node-fetch]
462 questions
1
vote
0 answers
fetch data in server
So, I have a server on amazon with my application, I need to do authorization with nodejs project. Using fetch, I tried to authorize but I get an error below my code.
async function Login() {
try {
const response = await…

alex
- 524
- 2
- 11
1
vote
1 answer
innerText value is undefined when returned from promise despite being there on the console
I'm using Node JS, here's the code
import fetch from 'node-fetch';
import { JSDOM } from 'jsdom';
import {Appartment} from "./models/Appartment.mjs"
let applist = []
let multipleDivs = []
async function kijAppartments() {
try {
…

mrnanse
- 11
- 1
1
vote
1 answer
Check if a Twitch Stream Is Live Using node js
I don't know how to combine them.
I made a code by referring to the link below.
Please Help me...
Android - Checking if a twitch stream is online
Is There Any Way To Check if a Twitch Stream Is Live Using Python?
setting
export const CHANNEL_NAME =…

gagore
- 15
- 4
1
vote
0 answers
Convert an imagen from an url to base64 without downloading it
I want to generate a pdf with images and text, for this I'm using the jsPdf package which includes this method to add images.
addImage(imageData, format, x, y, width, height, alias, compression, rotation)
The imageData argument accepts base64…

GhostOrder
- 586
- 7
- 21
1
vote
1 answer
Implementing retry logic in node-fetch api call
I hope you will forgive the beginners question, I'm trying to implement a simple retry policy for an api call using node-fetch
This is being added to an existing repo using TypeScript so I'm using this also, hence the data definitions.
async…

Steerpike
- 1,712
- 6
- 38
- 71
1
vote
1 answer
How to save a file from rest API response using node-fetch in NodeJS?
when I am making an API request and trying to store the file from the response, it's giving me an error
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an…

Sumit Singh Jodha
- 51
- 1
- 7
1
vote
1 answer
node-fetch response.json() terminates application inside a try catch
I'm pretty sure this is caused by the JSON being empty but I'm trying to get the current song I'm playing on Spotify using node-fetch, any attempt at even calling response.json() causes the application to exit with this error:
SyntaxError:…

Keelan Kelly
- 11
- 2
1
vote
1 answer
RangeError [MESSAGE_CONTENT_TYPE]: Message content must be a non-empty string
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (commandName === 'denick') {
await interaction.deferReply();
const data =…

birdlol
- 21
- 2
1
vote
1 answer
How to cast a Promise?
I use fetch to query some JSON data from an API.
The helper function I wrote returns a Promise (this is a simplified version)
const apiCall = (): Promise => fetch('http://the.api.com').then(r => r.json())
I then use it like…

WoJ
- 27,165
- 48
- 180
- 345
1
vote
1 answer
AWS S3 presigned url upload returns 200 but the file is not in the bucket using NodeJS & node-fetch
These are the relevant dependencies in my package.json:
"dependencies": {
"@aws-sdk/client-s3": "^3.52.0",
"@aws-sdk/node-http-handler": "^3.52.0",
"@aws-sdk/s3-request-presigner": "^3.52.0",
"axios": "^0.26.0",
"body-parser":…

Carlos Jaime C. De Leon
- 2,476
- 2
- 37
- 53
1
vote
1 answer
Calculate difference between two timestamps
I'm using the twitch api and TMI.JS
I'm trying to fetch the timestamp of followed_at. The timestamp I got was 2021-12-25T15:49:57Z, how would I go about getting the current timestamp, and then calculating the difference. So in this instance it would…

Epicurious
- 67
- 8
1
vote
1 answer
How to download files with node-fetch
I need help implementing a file downloader in nodejs.
So i need to download over 25'000 files from a server. Im using node-fetch but i don't exactly know how to implement this. I tried using Promise.allSettled() but i also need a way to limit the…

magic88
- 11
- 2
- 4
1
vote
1 answer
How to get all of the members of a guild with a certain role in discord.js v13
I'm currently working on a discord.js bot to start getting some practice with node.js
I have currently run into a problem when trying to get all the members of a guild with a certain role. Here is the relevant code:
const { SlashCommandBuilder } =…

Verve
- 58
- 1
- 10
1
vote
1 answer
node.js node-fetch - problem passing query string appended to url
I am calling an API from node.js. The documentation specified a query option appended to the url.
The API documentation shows something like this:
curl -L -X POST https://API_URL_GOES_HERE/library?format=txt -H "Authorization: Bearer…

Marlowe
- 33
- 4
1
vote
2 answers
(CLOSED) TypeError: fetch is not a function, What did I do wrong?
I'm trying to use node-fetch in order to fetch this website that has this JSON file where I can use it for my discord bot.
Code (JS):
const fetch = import("node-fetch")
// some code until
data = ""
try {
data = await…

Baselistic
- 57
- 1
- 1
- 8