Questions tagged [superagent]
410 questions
7
votes
1 answer
Mocha Test: Uncaught TypeError: Cannot read property 'status' of null
Learning TDD and my first simple test for my "Hello World" server response is failing in Mocha. I'm using Mocha.js, Superagent, & Expect.js.
When I curl -i localhost:8080, I get the correct response and status code.
HTTP/1.1 200 OK
Content-Type:…

metame
- 2,480
- 1
- 17
- 22
6
votes
2 answers
“the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded” from superagent in Android React Native
I'm using superagent to upload files from my React Native app. It works perfectly fine on iOS, but on Android it gives this error:
Possible causes: the network is offline, Origin is not allowed by
Access-Control-Allow-Origin, the page is being…

alt
- 2,356
- 2
- 21
- 28
6
votes
1 answer
Testing binary response with supertest
I'm developing an API with express and testing it with supertest. My API endpoint is returning tar.gz file. I would like to test, if file is properly sent and it's content is correct. I'm having troubles figuring out how to retrieve data. My naive…

David Vass
- 135
- 7
6
votes
1 answer
GatsbyJS & Superagent: WebpackError: require is not a function
I'm trying to build my react app into static html pages with gatsbyjs. I just tried 'gatsby build', and it goes through everything fine until it wants to create the static pages, then I get:
error Building static HTML for pages failed
See our docs…

George Welder
- 3,787
- 11
- 39
- 75
6
votes
1 answer
Read Authorization header from response
I am working on a side project in which I want to reuse an existing API.
The API has an /auth endpoint which handles POST requests and expects the email and password in the request body. If the email and password are verified, then the server…

cvetanov
- 363
- 1
- 3
- 12
6
votes
1 answer
Different NODE_ENV for different tests
I'm testing my API with supertest
I want to check that my CSRF token protection works, and then disable it for the other tests.
For this I set NODE_ENV to test or not_test
app.js
var csrf = require('csurf');
var app = express();
if…

IggY
- 3,005
- 4
- 29
- 54
6
votes
3 answers
React/Redux + super agent, first call gets terminated
I am writing a react-redux app where I am making some service calls in my middlewares using superagent. I have found a very strange behavior where the first call to my search api always gets terminated. I have tried waiting 10-30 seconds before…

ajmajmajma
- 13,712
- 24
- 79
- 133
6
votes
1 answer
Beego POST request body always empty
I'm working with Beego's convenience methods for parsing request body values and have the following:
Router file:
apiNamespace := beego.NewNamespace("/api")
apiNamespace.Router("/sessions/google/new", &controllers.SessionsController{},…

rawfish.dev
- 319
- 3
- 13
6
votes
0 answers
How to use superagent when testing in Jest-CLI?
I need to fetch some real data in my tests from a remote url. I Superagent is not being mocked. I have done that by including node_modules/superagent/ in unmockedModulePathPatterns.
This is the file I am trying to test, the .end() function is never…
user916367
5
votes
1 answer
How do I send an Object along with an attached File in a Multipart superagent request?
I am trying to make a multipart POST request to my API using superagent.
My Code:
superagent
.post(apiUrl + '/api/company/profile/edit')
.field("profileData", profileData)
.attach('company_logo', logoFile )
.set('Accept',…

Andrew Font
- 1,245
- 3
- 19
- 38
5
votes
3 answers
OWIN Login slow performance >30 Seconds
I have a big performance issue when i try to login with my application. The application is a Web api app hosted in Azure. I use react js for my front end.
And in my SimpleAuthorizationprovider i am fetching the user and adding claims to the…

Andreas Jangefalk
- 337
- 1
- 4
- 20
5
votes
1 answer
"The keyword yield is reserved" eslint error
I'm attempting to use Webpack 1.13.12 and eslint 3.11.0 and eslint-plugin-promise 3.4.0. I'm trying to use the answer in this question to get Superagent to yield the result of a web service call.
import agent from…

Brad
- 2,261
- 3
- 22
- 32
5
votes
1 answer
Extending SuperTest
I like to use SuperTest to work with my auth system like this:
const request = require('./valid_access_token')(require('supertest'));
request(app)
.get('/v1/bots')
.valid_token()
.expect('Content-Type', /json/)
…

Stan Wiechers
- 1,962
- 27
- 45
5
votes
5 answers
Unexpected end of MIME multipart stream. MIME multipart message is not complete. Web API and superagent
I have a problem with uploading files from client to web api. I am getting this error "Unexpected end of MIME multipart stream. MIME multipart message is not complete." in the controller when i am trying to read the multipart content. I ma building…

Andreas Jangefalk
- 337
- 1
- 4
- 20
5
votes
1 answer
How to make superagent return a promise
I've been learning Node/Javascript, using promises from the start (I don't know how to not use promises and often wonder how others get along without them).
So I sometimes need to "promisify" simple stuff like reading a file with fs:
var readFile =…

user1272965
- 2,814
- 8
- 29
- 49