Questions tagged [node-fetch]
462 questions
0
votes
1 answer
How to POST to Spotify API token endpoint with JavaScript?
I'm running following js-code. But I keep getting an error from Spotify Webpage (saying there was some sort of error).
credentials is a base64 encoded string of client_id and secret.
The curl-command works just fine:
curl -X "POST" -H…

maddingamer
- 15
- 3
0
votes
0 answers
Use a variable outside the node fetch function
This is what my code currently looks like:
const fetch = require('node-fetch');
let url = `WEBSITE_URL`;
let settings = { method: "Get" };
fetch(url, settings)
.then(res => res.text())
.then((text) => {
json = text.replace(/'/g,…

EvernoteMC
- 3
- 1
- 4
0
votes
2 answers
Replace character in raw data before parsing to JSON using node-fetch
I'm trying to fetch raw data from a website and convert it into JSON, but the problem is that the data uses single quotes instead of double quotes, which gives an error
UnhandledPromiseRejectionWarning: FetchError: invalid json response body at…

EvernoteMC
- 3
- 1
- 4
0
votes
1 answer
How to get a response from async fetch request? (node-tetch)
I'm using node-fetch for a simple HTTP POST request but I'm unable to get a response from it?
I'm getting follwoing error:
(node:7200) UnhandledPromiseRejectionWarning: FetchError: invalid json response
body at url reason: Unexpected token А in JSON…

J. Doe
- 75
- 1
- 1
- 10
0
votes
1 answer
Piping Remote files in Node JS looking for alternative ways
I was using a request module and that is deprecated now. It was useful to pipe the remote files without storing in server. So looking for an alternative solution of the same function with Node-fetch, GOT, Axios etc..
import request from 'request';
…

Bala.Raj
- 1,011
- 9
- 18
0
votes
1 answer
Could not interpret "{}" as string
So i'm developing a discord bot and i want to make a command that when the user types ".doggo" a random image of a dog appears. This is the code i have for the current command. I have the node-fetch and discord.js libraries installed to the…

lapetus
- 1
- 1
0
votes
1 answer
NodeJS - Calling Fetch in a Function hangs the console
I was getting an issue in my React client side, so I reproduced the error using a simpler single file node program. In the react client, I'm not getting any data back. Using Postman, I'm able to do a "Get" and retrieve the JSON data.
Can someone…

NealWalters
- 17,197
- 42
- 141
- 251
0
votes
1 answer
I want to send JSON data from node-fetch api to the browser and update data every 900 miliseconds. How can I do that?
I have an issue where I want to send a response to my client-side. I have written a server with Express.js created all the routes and hooked all the things up together. My default view engine is configured as EJS. I don't want to just log the values…
user13924257
0
votes
1 answer
fetch JSON data dynamically in NodeJS REST api
I am trying to fetch JSON data from API. I am using node-fetch in my express app. I am able to fetch data if I enter the absolute URL. But I am looking to fetch data entered in req.body like this
app.post('/data', async(req, res) => {
const url =…

kelly
- 115
- 1
- 5
0
votes
0 answers
Consuming external API from Hapi js server on startup not returning a promise
I am new to Hapi and I want to consume an API when the server starts up. I on start-up I am getting "Error: handler method did not return a value, a promise, or throw an error."
I came across this post and was trying to model my code after the…
0
votes
2 answers
Firebase function using node fetch returns certificate error
I have a firebase function which is running under Node.js 8 on a Pay-as-you-go Blaze plan. It is quite simple. It just uses node-fetch in order to execute an HTTP request:
…

user2128702
- 2,059
- 2
- 29
- 74
0
votes
1 answer
How to send raw request using node-fetch?
node-fetch can be found here: https://github.com/node-fetch/node-fetch
I want to send a plain request such as:
GET /search?q=test HTTP/2
Host: www.bing.com
User-Agent:
Accept: */*
I have no idea how to do that, or if it possible at…

uIM7AI9S
- 353
- 4
- 13
0
votes
1 answer
Getting an empty response from HERE GEO API using fetch i Node.js
I am trying to send a request to 'HERE' Geo API from a node.JS code and getting an empty response
This is what i am doing:
const fetch = require('node-fetch');
const http = require('http');
const https = require('https');
const keepAliveAgent = new…

Ofer B
- 369
- 2
- 5
- 14
0
votes
1 answer
How to write response to stream without waiting end of the fetch?
I need to fetch an audio file and write in a directory. I am worried about that I have to wait end of the fetch to download all the file and then write/save to file. Is that possible to fetch audio file and at the same time write in a file. I just…

Çağatay Sert
- 413
- 2
- 5
- 16
0
votes
0 answers
Receiving and internal server error 500 when making a post request from a google cloud function
I actually found this exact question on the site previously, however the solution for their problem did not solve mine.
Below is my code for my google cloud function:
exports.makeOrder = functions.https.onCall(async (req, res) => {
try {
const…

Cristian
- 51
- 6