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
0
votes
1 answer

Requests with status 400 (Bad request) doesn't pipe the correct body

request 2.83.0 node 8.11 yarn 1.5.1 Operating System: Windows Server 2012 R2 We're using request to power our proxy. It works well for all requests, and we're even transferring big files (400MB), all methods work and etc. We create our options…
petur
  • 1,366
  • 3
  • 21
  • 42
0
votes
1 answer

how can I convert object to raw text?

I need to send a request. If I have copied this request and executed on postman and it works. Postman is sending it as a raw. Is there anyway that I can convert my formData object to raw? I tried to use the lib npm i form-urlencoded and encodeURI…
Tiago Castro
  • 421
  • 6
  • 20
0
votes
3 answers

Can't set headers after they are sent in get request

router.get('/getpostcode', function(req, res){ console.log(req.query.suburb); var options = { url: 'http://apiurl?suburb=' + req.query.suburb + "&state=" + req.query.state , headers: { 'auth-key': key } …
Mac Ahmed
  • 55
  • 10
0
votes
0 answers

initialize variables on request nodejs to construct Object

I have a little bit problem with my variables. I would like construct Object (ObjectQueue) at return on my function but i can't because variables initalized in my callback function request have no the same scope and i don't find solution. The…
Jerem
  • 1
  • 2
0
votes
1 answer

Unable to send request from request callback

I cant execute a second request inside the request callback. request({ url: url, headers: { 'auth-token': token }, method: 'POST', json: true, body: data }, (err, req, body) => { if (err) { …
zer09
  • 1,507
  • 2
  • 28
  • 48
0
votes
1 answer

Requestjs has two different syntaxes: one as an array, one as an object

I am trying to run a script that looks like this: const response = await request.getAsync(channelAPI); let responseData = JSON.parse(response[0].body); However, when I run this on one machine it works, whereas the other just returns the…
Anthony
  • 13,434
  • 14
  • 60
  • 80
0
votes
2 answers

limit concurrent operations nodejs

This is a web scraping code written in node js. Will this code always keep 5 concurrent request when queue has enough urls? Why the console shows otherwise? var request = require("request"); var cheerio = require("cheerio"); var fs =…
rishabh dev
  • 1,711
  • 1
  • 15
  • 26
0
votes
1 answer

JSReport API. Save PDF from Response

Using JSReport to generate some output for print, and I'm having some trouble saving the PDF file that is returned from the API. I'm using this code to save the file: var options = { method: 'POST', url:…
Chris Rutherford
  • 1,592
  • 3
  • 22
  • 58
0
votes
1 answer

Promises and Express 4.x - TypeError: Cannot read property "then" of undefined

[EDIT] While trying to implement the promise I get the following error: TypeError: Cannot read property "then" of undefined getResult(options1).then(function(body){... let options1 = {...}; app.post("/webhook", function (req, res) { if…
rrampaer
  • 21
  • 3
0
votes
1 answer

writing file from post request in ExpressJS

Working with express to create a file transfer tool, and I've almost gotten everything completed. Just need to figure out how to get the data from the request written to file. My issue appears to be stemming from not knowing where the file contents…
Chris Rutherford
  • 1,592
  • 3
  • 22
  • 58
0
votes
1 answer

Why does NodeJS request() fail on localhost in flight mode, but not 127.0.0.1? (Windows 10)

Given I already have a server up and running on localhost (see further down for an example), at a node command line while online, I get the following: > var x = request('http://localhost:8080/test.html', ... function(err) { if (err)…
Dave E
  • 612
  • 6
  • 13
0
votes
1 answer

Promise chain not getting executing properly

I've a promise chain in my nodejs code, I couldn't understand why the second 'then' part is being executed before the first 'then' part completes it execution. Can someone help me understand what is wrong with the below code. .then(model=>{ …
Ajay Srikanth
  • 1,095
  • 4
  • 22
  • 43
0
votes
0 answers

javascript/nodejs code returning undefined

Trying to run this code in nodejs but this returns undefined. but if i do "console.log(status)" inside de "client.get" function, this shows the right value. i'm using request-json node package. i would like a good explanation about, please. let…
0
votes
0 answers

Express js post multipart form data to external API

I have an angular application and express server a middle ware which call the external API $scope.uploadLayout = function(){ $scope.selectedTemplate.selected = $scope.items; var fd = new FormData() fd.append('name',…
ashu gupta
  • 41
  • 7
0
votes
1 answer

Set Cookies via String

I'd like to use requestjs to make requests and share the cookies between multiple javascript files and even multiple servers. For that reason I'm storing the cookies in a database as a string and retrieve them when needed. The string looks like this…
maddo7
  • 4,503
  • 6
  • 31
  • 51