Questions tagged [node-fetch]

462 questions
-1
votes
1 answer

Use node-fetch v2.6 to get HTML of a website

Currently my code is the following: const fetch = require("node-fetch"); (async function () { console.log(await fetch("https://a.website.in-ht.ml")); })() However, It is only returning data on the website, as opposed to the HTML. Anyone know…
-1
votes
1 answer

Node-fetch does not send anything in post request

I am trying to make a request to an api with node-fetch. I've followed the documentation but it doesn't seem to do anything. I have modified the options and it seems that nothing has changed. Headers and body are ignored. When I test with postman…
Mat
  • 33
  • 1
  • 7
-1
votes
1 answer

NodeJS : While loop check the status untill sucess in fetch

I have the below code which call api and get status using node-fetch . I need to use node-fetch 2.6.1 and use the code like .then-->.then cannot able to use async await . function fetching(){ fetch(jobsurl, requestOptions) .then(response =>…
Rajarshi Das
  • 11,778
  • 6
  • 46
  • 74
-1
votes
1 answer

Unable to resolve module node:http

Description? I'm working on a ReactNative app, and I was trying to make an HTTP request on an API. The implementation in use works fine (I've been using it for a while now). But with this new version 3.2.0, when i import the file, I immediately…
-1
votes
1 answer

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

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 webpage to work with that content for a project I…
noxter
  • 186
  • 1
  • 11
-1
votes
1 answer

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/deck/new/shuffle/deck_count=1") .then(res =>…
-1
votes
3 answers

Retry fetch request doesn't return anything

This is the current code and what I've come up with: function getToken() { return new Promise(async (resolve, reject) => { try { let res = await fetch(url); if (res.status === 418) { …
Nitsua
  • 235
  • 2
  • 8
-1
votes
1 answer

Getting response text from node fetch

I'm fairly new to node fetch and I'm doing a simple get request to get a list of my postman collections. I'm able to get the response text and console log it in the function but when I'm returning the responseText to a variable and logging it, I get…
-1
votes
1 answer

Extract the price only from api using node-fetch array

I am sorry for a basic question, I have been trying to extract only the price using node-fetch from API const fetch = require('node-fetch'); fetch('https://api.binance.us/api/v3/avgPrice?symbol=DOGEUSD') .then(res => res.text()) .then(text…
-1
votes
1 answer

Dark magic going through res.json()

To avoid the XY problem, here's my final goal: I want to fetch something, use the response body, and return the response (from which the user should be able to get the body) without returning the body separately. On the paper, this should…
deb
  • 6,671
  • 2
  • 11
  • 27
-1
votes
1 answer

How to forward multipart form request with node-fetch

I am trying to forward a graphql upload file through a node server. In my graphql resolver I have: async uploadFile ({ file }) { const { createReadStream, filename } = await file; const form = new FormData(); const fileBuffer =…
Eva
  • 19
  • 2
-1
votes
2 answers

POST request with form data fails after switching from request-promise to node-fetch

I've replaced request-promise with node-fetch. Everything works well except for one request, which sends form data to an endpoint that I, unfortunately, can't provide here. This is the code that works with request-promise: const options = { …
jz22
  • 2,328
  • 5
  • 31
  • 50
-1
votes
2 answers

fetch not working result is undefined in Node.js

I am running a webhook to pull and process data from seller.tools api. I am trying to call their api with a fetch using node-fetch. When I am testing it in the cloud9 ide, to transfer it to aws-lambda, anyway I try and grab the result it comes as…
Robert Fiola
  • 1
  • 1
  • 3
-1
votes
2 answers

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

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((result) => result.text()) .then((body)…
Darmon
  • 303
  • 4
  • 17
-1
votes
1 answer

Error when tryign to start the bot with node-fetch

I'm currently setting up a premium queue bot from previous code but I need to switch from snekfetch to node fetch I've tried using the get function yet to no avail it comes out as nonexistent run(msg, { user }) { …
1 2 3
30
31