Questions tagged [superagent]

410 questions
1
vote
2 answers

getting bad request instead of full error message

I am trying to do error handling for POST with the same user email with the following(using superagent): export function signUpUser(userData) { return async dispatch => { try { const currentUser = await…
leogoesger
  • 3,476
  • 5
  • 33
  • 71
1
vote
1 answer

How to handle 401/403 responses from server optimally on global level

Currently, I'm using a helper function and an if condition which pushes the current location to /login whenever there's a 401(unauth) or 403(forbidden) response from the api, like this: request.get(//api url here) .set('Accept',…
m-ketan
  • 1,258
  • 2
  • 17
  • 23
1
vote
0 answers

IPFS can't unpin from the API

I'm working on a react app using IPFS to store files, currently using superagent for making the requests. I can add files no problem from the web app for example: URL:…
Shan Robertson
  • 2,742
  • 3
  • 25
  • 43
1
vote
1 answer

Mocha test if the Http Request Promise throw: Unhandled promise rejection

I'm trying to test if my Http Request method throw an error, but I always got: Unhandled promise rejection. This is my test: it('it should get the first page of all offers with limit 20 without a cache system', (done) => { const…
Mike Boutin
  • 5,297
  • 12
  • 38
  • 65
1
vote
0 answers

Testing multiple simultaneous sessions with mocha-chai superagent

I am trying to write tests for multiple socket connections, which I need to have multiple sessions (simultaneously) for since they are identified by session ID on the server side... In the example below client1 will connect and the handshake will…
Koborl
  • 235
  • 1
  • 11
1
vote
2 answers

How to do javascript request (supertest, superagent) behaving like curl --data-binary

tl;dr; Sending below curl works but I cannot do the same in supertest (what wrap superagent https://github.com/visionmedia/superagent/) curl 'http://local/api/items' -X DELETE -H 'Accept-Encoding: gzip, deflate' -H 'content-type:…
pbaranski
  • 22,778
  • 19
  • 100
  • 117
1
vote
1 answer

Express API with JWT returns "Unauthorized: Invalid Algorithm error"

I've written a simple React app, following the instructions of a slightly out of date tutorial that is meant to display a list of contacts in the sidebar with individual contact data displayed in an index component but only if you have been…
Bryan White
  • 334
  • 1
  • 13
1
vote
1 answer

Messenger Bot "sleep mode" getaddrinfo

I got a bot made in nodejs (expressjs) and hosted on my private VPS, I encounter a bug with HTTP request made with superagent lib. When there is a long period of inactivity, the nodejs server is like in "sleep mode", and the first request is always…
Paul
  • 101
  • 1
  • 1
  • 12
1
vote
2 answers

superagent post vs put in react

var request = require('superagent'); var url = 'api/server'; request.put(url) .set('Content-Type', 'application/json') .send('{"name":"tj","pet":"tobi"}') .end(function(err, res){ if (err) throw err; …
tracer_rock
  • 165
  • 1
  • 3
  • 9
1
vote
0 answers

Express JS: Superagent does not use http-proxy-middleware

I am writing a node application using express JS. Usually in this application we consumes res apis and merge them in one object and send it to angular application. As a rest client I am using superagent. One of my colleague has written reverse proxy…
1
vote
1 answer

How can I make the redirect wait for the response from the server?

first of all I want to mention that I'm completely new to react and javascript in general, I went through a lot of similar question threads however none of the solutions seemed to help as they mostly generated more errors. The project I'm working…
blai
  • 21
  • 1
1
vote
1 answer

How do you upload a file to a pre-signed POST URL from a browser to Minio or S3 using javascript

This article shows how to upload a file to Amazon S3 or minio using a form. I want to use the pre-signed POST URL policy method, since it appears to be the most secure. However, I wish to upload a file programmatically to minio or S3 using a…
Paul S
  • 892
  • 10
  • 25
1
vote
0 answers

Can't properly save .mp4 files on server using flask

I have a problems saving video files on server using flask. Here is my client code( I am using react and super agent): onDrop(files){ var req = request.post('/upload'); files.forEach((file)=> { req.attach('videoFile', file); }); …
1
vote
2 answers

Superagent with absolute url prefix

I've noticed that I'm writing http://localhost everytime I want to run a node test with superagent. import superagent from 'superagent'; const request = superagent.agent(); request .get('http://localhost/whatever') .end((err, res) => { ...…
zurfyx
  • 31,043
  • 20
  • 111
  • 145
1
vote
0 answers

How can I test superagent promises using Jasmine?

I'm using VueJS 2.0 with SuperAgent in order to create an API client connector. I'm working on test coverage for my API and having trouble when it comes to test SuperAgent methods itself. I need to know how to spy on my private methods within…
Anna
  • 469
  • 1
  • 6
  • 20