Questions tagged [requestjs]

Request - Simplified HTTP client

Request is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default.

var request = require('request');
request('http://www.google.com', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Show the HTML for the Google homepage.
  }
})

Available Options

  • Streaming
  • Forms
  • HTTP Authentication
  • Custom HTTP Headers
  • OAuth Signing
  • Proxies
  • Unix Domain Sockets
  • TLS/SSL Protocol
  • Support for HAR 1.2

Request in GitHub

Request in npm


Deprecated Warning!

As of Feb 11th 2020, request is fully deprecated. No new changes are expected to land. In fact, none have landed for some time.

For more information about why request is deprecated and possible alternatives refer to this issue.

143 questions
2
votes
1 answer

POST request via requestJS to send Array of JSON Objects and image files

I'm building REST API with NODEjs, using Express routers and Multer middleware to handle multiple body data and files. My endpoint route 127.0.0.1/api/postData expects: json data with fields, one of which is array of json objects (I'm having nested…
JavaJedi
  • 221
  • 5
  • 16
2
votes
2 answers

How to find where form parameters are stored and use them in Request

I am trying to scrape https://www.freelance.nl/opdrachten/zoeken for data using Request and Cheerio but I am running into issues posting search terms. I cannot see where the search string and selected category are sent during the post when using the…
user2248441
  • 289
  • 2
  • 4
  • 22
1
vote
1 answer

Axios returns 500 error while request returns the response

I have call an API from my javascript code using the requests package. But since it is deprecated, I want to replace it with axios. The call is like this: request({ url: 'the_url', method: 'POST', encoding: null, headers: { …
Tasos
  • 7,325
  • 18
  • 83
  • 176
1
vote
0 answers

How do I convert a post request from request js to got js that contains a stream parameter

I am migrating a library from request to got and am getting stuck with a specific type of post request. The endpoint looks for a specific body which contains a filename and a stream of the file being uploaded. I have been unable to get this working…
APW
  • 420
  • 4
  • 15
1
vote
0 answers

express.js and request.js - incomplete PDF transfer when using callback syntax

Simplified question why, when using express.js & request.js following two examples: request.get(url) .on('response' (requestjsResponse) => { requestjsResponse.pipe(res); }) and request.get(url, (err, requestjsResponse, requestjsBody) => { …
Tomas
  • 3,269
  • 3
  • 29
  • 48
1
vote
1 answer

Very simple API request fails with Request.js, works with Curl

Simple query to an API, the curl request works, but fails when I try to utilize the request NPM module to perform the request. Curl: curl…
Dygerati
  • 646
  • 1
  • 6
  • 16
1
vote
1 answer

How to send a file from node to Amazon S3 using request?

I'm trying to send a file using fs.createReadStream() but it doesn't work or give any errors. I tried using request to put the file to s3 after steaming it from node. const fs = require("fs"); const request = require("request"); const path =…
hussam
  • 174
  • 1
  • 10
1
vote
1 answer

How to download files one by one in node js?

I'm trying to download multiple file using request library, I need to download them one by one and also show a progress bar, the files links are stored in an array that passes them to a function to start the download const request =…
1
vote
1 answer

Invalid Chai property: setEncoding on nock

I was using nock 9.1.6 to mock nylas API with chai 3.5.0. It was working perfectly with the code: it('fails when no state is given and provider fails', () => { const user = fixture.elements.user1; const connector = new NylasConnector('nylas',…
Jérémy Pouyet
  • 1,989
  • 6
  • 28
  • 55
1
vote
1 answer

Multiple Website Status Check with Node JS

I want to run a node app that would check multiple websites and responds with the proper status code. I am using the 'request' module of Node itself. The code I have is: const request = require('request') function getStatus() { …
1
vote
3 answers

Scraping with NodeJS

I need to extract links from the url in loop , so basically I need to execute another time the function but I don't know how to made this with nodejs. var request = require('request'); var cheerio = require('cheerio'); var searchTerm =…
kikes
  • 115
  • 6
1
vote
1 answer

How do you mock/test requestjs requestcallback with Jest

I am making a get request to an API using requestjs and then in the requestCallBack mapping the body to a custom json object. I am trying to test this code using Jest but no matter how I mock it, it doesn't seem to work I have tried…
Austin Mehmet
  • 448
  • 4
  • 13
1
vote
1 answer

Transforming a payload from requestjs before sending it to the client

Brothers and sisters, I am building an Express API Endpoint that needs to consume an external API, perform some changing of keys and values, and return to the result to the client. Here is what I have thus far: const external_endpoint =…
1
vote
0 answers

Returning body instead of string

I have a code similar to this: // src/getSessionId.js function callback(error, response) { // some code return sessionId; // typeof string } async function getSessionId(url = DEFAULT_URL) { const sessionId = await request.post(url,…
Neskews
  • 764
  • 1
  • 10
  • 23
1
vote
0 answers

Kubernetes drops long HTTP GET connection initialized in node.js

I have a very simple piece of code written in node.js (see below example) which runs on Kubernetes on GCP and AWS. The app just does GET request to import data from an external application. Sometimes that GET request could take ~30 mins or more.…
1 2
3
9 10