Questions tagged [superagent]
410 questions
5
votes
1 answer
Error importing superagent in React code
I have a NodeJS server code written in JSX where I'm importing superagent like so:
import request from 'superagent';
When server starts after build, I get the following error:
TypeError: require is not a function. And this happens at the following…

SherinThomas
- 1,881
- 4
- 16
- 20
5
votes
1 answer
SuperAgent + Node.js Connection Refused
I'm pretty new to Node.js so this is possibly an basic understanding issue, but I'm getting ECONNREFUSED from a superagent http request when I don't think I should be:
$ curl http://localhost:5000/
{"you": "looking good"}
$ node
> var request =…

JP.
- 5,507
- 15
- 59
- 100
5
votes
3 answers
keep-alive connection with Superagent
I'm running a node.js server A which uses superagent to issue HTTP requests to another server B.
I investigated the request on server B and saw the the header connection being close and the httpVersion being 1.1:
var http = require('http');
var…

dknaus
- 1,133
- 12
- 16
5
votes
1 answer
Encoding issue with superagent
I am trying to perform an API call with superagent but it encodes my api key which gets rejected.
get(url).query({ key: 'Fmjtd%7Cluu').end(function(err, res) {
The key is being sent as
Fmjtd%257Cluu
Any ideas how to prevent this using superagent?…

cyberwombat
- 38,105
- 35
- 175
- 251
5
votes
2 answers
How do I prevent SuperAgent AJAX from calling OPTIONS?
I found the source of my problem for SuperAgent (http://visionmedia.github.com/superagent/) on Firefox. Not sure if SuperAgent is doing it in its AJAX call or if FireFox is triggering it.
Essentially, every time I make an AJAX call an OPTIONS method…

crockpotveggies
- 12,682
- 12
- 70
- 140
4
votes
1 answer
Prevent password manager from asking to save password on xhr request
We are sending requests to an external API. It is an public API but still requires to sent basic auth authentication. Since it is a public user with no further access this is no security issue. But when those requests are executed the password…

Daniel
- 971
- 9
- 23
4
votes
0 answers
OpenAPI Warning: .end() was called twice. This is not supported in superagent
I generate my sdk with openapi-generator with the following command :
docker run --network=host --rm \
-v $(pwd)/clients:/tmp \
openapitools/openapi-generator-cli:v{open_api_generator_version} generate \
-i {url}/openapi.json…

Thytu
- 73
- 4
4
votes
1 answer
TCP session reuse in Superagent
I'm using superagent and while inspecting the network I noticed that superagent is creating a new TCP connection for each request. I'm using superagent for a sequence of requests which results in a large number of TCP connections (can reach several…

Rivi
- 791
- 3
- 15
- 23
4
votes
1 answer
Redux saga using parameters of other instances of the class
I have four different instantiations of an API class, three of which have the same parameters, and one which has different ones. However, the class with the different parameters seems to be instantiated with the parameters of the other three…

gabym
- 43
- 4
4
votes
3 answers
reactjs - interrupting a post request in superagent
I am trying to calculate the progress of a file upload, so I was using Superagent. I was able to get the progress of the file upload.
Now when a user selects the cancel button, I need to interrupt or cancel the post request. Is there any way to do…

Jeril
- 7,858
- 3
- 52
- 69
4
votes
2 answers
Mocking superagent post request with nock not matching
I cannot for the life of me get nock to work with a simple superagent post request. Here is both my superagent and nock configuration.
superagent:
request
.post('https://test.com/api/login')
.send({
email: 'test@test.com',
password:…

ThinkingInBits
- 10,792
- 8
- 57
- 82
4
votes
2 answers
Superagent with Webpack: "require is not defined"
I am working on a React/Redux project, and have been struggling to get superagent working.
After following issues in the superagent issue and adding some workarounds to my webpack.config file, I was able to build my bundle with no errors.…

hoodsy
- 894
- 2
- 11
- 19
4
votes
1 answer
How to get rid of supertest's output when testing express applications?
I'm building an Express.js API and I'm using mocha and supertest for testing.
However, take a look at this:
root path
GET / 200 5.789 ms - 19
✓ returns 200 status code
GET / 200 0.787 ms - 19
✓ returns json mime type
GET / 200 0.382 ms -…

brielov
- 1,887
- 20
- 28
3
votes
1 answer
How to extract a cookie from a superagent response?
I'm using Superagent's agent() method to enable cookies when making HTTP requests. This is my code:
const agent = request.agent();
const login = await agent
.post("http://localhost:3000/login")
.field("email", "john@doe.com")
…

Adam Arold
- 29,285
- 22
- 112
- 207
3
votes
1 answer
How do I use aysnc/await in this superagent call?
This is a superagent call, I have imported request(i.e is exported from my superagent component class)
How do I use async/await in this for "res.resImpVariable".
request
.post(my api call)
.send(params) // an object of parameters that is to be…
user13651619