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
142
votes
2 answers

Getting binary content in Node.js using request

I was trying to GET a binary data using request, and had something like: var requestSettings = { method: 'GET', url: url, }; request(requestSettings, function(error, response, body) { // Use body as a binary Buffer } But body was always…
GilZ
  • 6,418
  • 5
  • 30
  • 40
21
votes
3 answers

What is the proper way to loop through an array in an EJS template after an AJAX Call (using ExpressJS)?

I am trying to loop through an array of objects that I got from an http call using to my internal API using the request module/package. So far, I am able to get my data back from the API and DISPLAY the full object on my page. I would like to…
AllJs
  • 1,760
  • 4
  • 27
  • 48
14
votes
2 answers

NodeJs ECONNRESET

I get an error when I'm executing GET request. Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' } It happens when I try to make GET request to…
Damian
  • 2,930
  • 6
  • 39
  • 61
11
votes
3 answers

stream response from nodejs request to s3

How do you use request to download contents of a file and directly stream it up to s3 using the aws-sdk for node? The code below gives me Object # has no method 'read' which makes it seem like request does not return a readable…
rynop
  • 50,086
  • 26
  • 101
  • 112
10
votes
1 answer

Node.JS Request - Invalid URI "/"

I'm using request in my app to send a POST request over HTTPS with Client Authentication. Request always throws an error Error: Invalid URI "/" and I couldn't do anything to solve it. I've tried used url.parse instead of passing a string but it's…
Nick Shvelidze
  • 1,564
  • 1
  • 14
  • 28
10
votes
1 answer

node express content-disposition

I want to force the browser to download a file from an external storage, given an url. I implemented this express controller post action: var download = function(req, res) { request(req.body.url).on('response', function(response) { …
bepi_roggiuzza
  • 195
  • 1
  • 3
  • 12
8
votes
1 answer

How to POST binary data in request using request library?

I have to send binary contents of a remote file to an API endpoint. I read the binary contents of remote file using request library and store it in a variable. Now with contents in the variable ready to be sent, how do I post it to remote api using…
Priya Ranjan Singh
  • 1,567
  • 1
  • 15
  • 29
5
votes
1 answer

Why do I get a CORS error on API Gateway GET request when the OPTIONS request has statusCode 200?

I am trying to make an GET HTTP request to a AWS API Gateway endpoint connected to a lambda function. The endpoint and lambda function work as usual when tested with postman which is logical since postman doesn't use CORS. However, when testing on…
5
votes
0 answers

request-promise: set timeout for long requests

I am using request-promise library and trying to set the timeout as milliseconds as per their documentation. I have few requests on the server side that take more than a minute to response, no matter what value I set for timeout, the request always…
Prasanna
  • 3,703
  • 9
  • 46
  • 74
5
votes
4 answers

"Header content contains invalid characters" error when piping multipart upload part into a new request

My express server receives file uploads from browsers. The uploads are transferred as multipart/form-data requests; I use multiparty to parse the incoming entity body. Multiparty allows you to get a part (roughly, a single form field like an
josh3736
  • 139,160
  • 33
  • 216
  • 263
5
votes
1 answer

Promise hangs even though it is resolved

I am using request-promise module to check whether site is working with proxy or not. I am trying to find the proxies which is fast enough to answer in 5 seconds. Therefore I only add object if request doesn't timeout in 5 seconds. For some proxies,…
Meanteacher
  • 2,031
  • 3
  • 17
  • 48
5
votes
2 answers

NodeJS request multiple api endpoints

Ok so I am trying to make two or more requests to API endpoints using the request module. I am rendering a HTML file and passing the returned JSON to a handlebars template using the below code: res.render('list.html', { title: 'List', data:…
stackunderflow
  • 1,644
  • 6
  • 24
  • 40
4
votes
1 answer

How can I access the response headers of a request that is piped to a feedparser

I am trying to parse an RSS feed using request js and feedparser-promised libraries. I am able to parse the feed using the below code. import Bottleneck from 'bottleneck'; const feedparser = require('feedparser-promised'); const limiter = new…
omnathpp
  • 135
  • 1
  • 2
  • 8
4
votes
4 answers

chai.request is not a function while using request js for http service unit test

I have been using karma+requestjs + mocha + chai and sinon. i have been using chai-http module yet receives chai.request is not a function.please suggest where i am making mistake i have googled lot no luck yet. (function() { var specFiles =…
aka
  • 199
  • 1
  • 4
  • 15
4
votes
2 answers

RequestJS - SSL connection is authorized but getPeerCertificate() returns null

I'm using the node package RequestJS v2.65.0 on node v4.1.2 I'm trying to read the SSL certificate from certain sites (eg. GitHub.com). This previously worked on node 0.12. On node 4.2.1, however, getPeerCertificate() returns null. For…
George
  • 65
  • 1
  • 5
1
2 3
9 10