node-fetch

keep fetching data up to date

限于喜欢 提交于 2021-01-29 14:26:12
问题 I have just a question I want to ask if anybody have an idea about it. I'm building a full stack application backed by nodejs and using typescript for it, in my nodejs app I'm making a fetch for an API that later on I will serve it to the user but I have one small issue, I'm using node-fetch for now but the data which are fetched are changing all the time eg. now I have 10 entries, after 5 seconds I have 30 entries, so is there a way or mechanism to make my fetching to the data with nodejs up

What does the 'maximum redirect' error in fetch-api means?

半世苍凉 提交于 2021-01-29 12:40:54
问题 I am trying to fetch some data from a website but got the following error: { FetchError: maximum redirect reached at: <URL> at ClientRequest.<anonymous> (C:\Users\Michal\Desktop\argentina\node_modules\node-fetch\lib\index.js:1498:15) at ClientRequest.emit (events.js:198:13) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17) at TLSSocket.socketOnData (_http_client.js:442:20) at TLSSocket.emit (events.js

How to ignore SSL certificate validation in node requests?

走远了吗. 提交于 2020-06-12 07:19:48
问题 I need to disable peer SSL validation for some of my https requests using node.js Right now I use node-fetch package which doesn't have that option, as far as I know. That should be something like CURL's CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false Does any networking package allow to do so? Is there a way to skip SSL validation in axios maybe? 回答1: Axios doesn't address that situation so far - you can try: process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; BUT THATS A VERY

dealing with an array of objects with promises

与世无争的帅哥 提交于 2020-05-24 03:51:47
问题 I am trying to make a node express app where I fetch data from different url's making a call to node-fetch to pull the body of some pages and other information about certain url endpoints. I want to then render a html table to display this data through an array of information. I am having trouble with the call to render the information as all the functions are asynchronous making it difficult to make sure all the promise calls have been resolved before making my call to render the page. I

Node-fetch: Disable SSL verification

走远了吗. 提交于 2020-05-14 17:18:07
问题 I have the following code, which is run from a express server: import fetch from 'node-fetch'; let formBody = []; const dataLogin = { 'username': 'myUser', 'password': 'myPassword' }; for (let p in dataLogin) { let encodedKey = encodeURIComponent(p); let encodedValue = encodeURIComponent(dataLogin[p]); formBody.push(encodedKey + "=" + encodedValue); } formBody = formBody.join("&"); const url = 'https://external-login-api.com'; return fetch(url, { method: 'POST', headers: { 'Content-Type':

Fetch with absolute url prefix

痴心易碎 提交于 2020-04-16 05:24:10
问题 Most of the times I prefix fetch or node-fetch with an http://localhost (to make it an absolute url). import fetch from 'node-fetch'; fetch('http://localhost/whatever') Is there any way of avoiding the localhost part, other than simply placing localhost in a variable? const baseUrl = 'http://localhost'; fetch(`${baseUrl}/whatever`) Very related to Superagent with absolute url prefix 回答1: TL;DR: fetch-absolute does exactly that. Detailed: You can create one abstraction layer on top of fetch.

response.body.getReader is not a function

随声附和 提交于 2019-12-24 13:01:09
问题 I'm making a call to a web api using fetch. I want to read the response as a stream however when I call getReader() on response.body I get the error: "TypeError: response.body.getReader is not a function". const fetch = require("node-fetch"); let response = await fetch(url); let reader = response.body.getReader(); 回答1: There is a difference between the javascript implementation of fetch and the one of node node-fetch . You can try the following: const fetch = require('node-fetch'); fetch(url)

Discord Oauth2 Join Guild

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 02:42:25
问题 const guildMembersResponse = fetch(`http://discordapp.com/api/guilds/440494010595803136/members/278628366213709824`, { method: 'PUT', headers: { Authorization: `Bearer TOKEN`, }, }); setTimeout(() => { console.log(guildMembersResponse) }, 500); I want to join a user to my Discord server with his userid and his token in nodejs, but if I request the Dicord api I get an error: Promise { Response { size: 0, timeout: 0, [Symbol(Body internals)]: { body: [PassThrough], disturbed: false, error: null