Questions tagged [superagent]
410 questions
11
votes
5 answers
Promises es6 and superagent
I'm attempting to use es6 promises with superagent. I'm attempting to call a function that has a superagent request wrapped inside.
Request.post(buildReq).then(res => {
if (res.ok) {//process res}
});
Here is the function wrapping superagent
…

rross
- 2,236
- 11
- 36
- 41
10
votes
4 answers
How to test image upload (stream) with supertest and jest?
I have an image upload endpoint in my API that accepts application/octet-stream requests and handles these streams. I'd like to write test coverage for this endpoint but cannot figure out how to use supertest to stream an image.
Here's my code so…

j_d
- 2,818
- 9
- 50
- 91
9
votes
0 answers
TypeError: str.charCodeAt is not a function
I updated to node version 6 today and that might've broke something. I tried to get back to node 5.10 but the issue didn't go away. Can this be related to the new V8 engine that is shipped by node v6?
Has anyone experienced this? Any idea?
The last…

haxpanel
- 4,402
- 4
- 43
- 71
9
votes
1 answer
Using Superagent/Supertest with Express app in Mocha tests
I am attempting to write tests for the REST API that I am developing, using Mocha. I discovered Superagent which lets me make HTTP requests. I am using an Express app, which I pass to Superagent, but I get strange errors about Mongoose when trying…
user1082754
8
votes
2 answers
superagent / supertest with async / await
Goal is to set the variable auth correctly for further use, hence i want to refactor the function loginUser:
function loginUser(user, request, auth) {
return function(done) {
request
.post('/users/login')
.send(credentials)
…

Gobliins
- 3,848
- 16
- 67
- 122
8
votes
4 answers
How to send files with superagent
So about a month ago I asked a question regarding superagent and sending files, but got no response at all. I would still like to find out how to do this as I enjoy using superagent.
I am able to send files using plain ajax:
var fd = new…

Julien Vincent
- 1,210
- 3
- 17
- 40
8
votes
4 answers
Javascript: How to spy on superagent with Jasmine?
I'm using the superagent ajax library for an app, and I'm trying to write some unit tests for it. I've got a class which looks like this:
someClass = {
getData: function(){
_this = this;
superagent.get('/some_url').end(function(res){
…

Kevin Whitaker
- 12,435
- 12
- 51
- 89
8
votes
1 answer
How i can pipe image file to upload endpoint with superagent?
/**
* Request png
*/
var request = require('superagent')
var req = request.get('http://example.com/original/' + id + '.png');
req.end(function(response){
// Here i want send responsed image to another server
…

user3843509
- 81
- 3
8
votes
3 answers
How do I send a request with superagent that uses the same query parameter
I am trying to make a request against a php server that is constructing the url like this:
website.com/?q=help&q=moreHelp&q=evenMoreHelp
How do I use superagent to pass the same query with multiple values?
I've tried…

Nathaniel Huff
- 85
- 1
- 1
- 5
7
votes
1 answer
How to send a formData object with supertest?
I just started to learn do test with supertest and mocha. I've read the api document of supertest and it said that supertest support all lower-level API provided by superagent. SuperAgent said we can send a formData object by:…

Feng Zhao
- 71
- 1
- 3
7
votes
4 answers
React Swiper with Dynamic Content
I'm making a carousel with images from Instagram using react-id-swiper. The Swiper component doesn't seem to be updating after the response. I thought that putting my setState inside componentWillMount would work but apparently not. When I open the…

Alex Smith
- 151
- 1
- 2
- 7
7
votes
0 answers
Cannot Basic Auth from React App with Axios or SuperAgent
I try to make a GET request with axios and I always get 401. This happens only when I send the request from my react app.
axios.get('http://localhost:8080/vehicles', {
withCredentials: true,
auth: {
username: 'admin',
…

Alexandru Hodis
- 372
- 4
- 14
7
votes
1 answer
How redirect to login page when got 401 error from ajax call in React-Router?
I am using React, React-Router and Superagent. I need authorization feature in my web application. Now, if the token is expired, I need the page redirect to login page.
I have put the ajax call functionality in a separated module and the token will…

Chris
- 6,431
- 10
- 44
- 59
7
votes
1 answer
Running Mocha tests with SailsJS and Superagent
I'm currently writing an app using SailsJS. What has been done so far works as expected when tested 'manually', but doesn't when tested with Mocha.
I tried to follow SailsJS testing guide, calling the test with npm:
[...]
"scripts": {
"start":…

fwoelffel
- 412
- 7
- 16
7
votes
2 answers
".use" method to add logic on each request of SuperAgent
This issue in SuperAgent repository mentions the .use method to add logic on each request. For example, adding an Authorization header for JWT when a token is available:
superagent.use( bearer );
function bearer ( request ) {
var token =…

Paulo Coghi
- 13,724
- 14
- 68
- 90