Questions tagged [superagent]

410 questions
3
votes
1 answer

TypeScript implicit any error with Superagent

I am using superagent in a TypeScript project and have installed @types/superagent but am seeing a type error I don't understand. Given the following... const myRequest = request .get('/path/to/api') .end((err, res) => { // Do stuff with err…
Michael
  • 1,643
  • 1
  • 15
  • 31
3
votes
2 answers

How to extend superagent with proxy method?

I haven't found any TypeScript definitions for superagent-proxy. So when I try to compile my TypeScript application to JavaScript, I get the error message: ts: Property 'proxy' does not exist on type 'SuperAgentRequest'. import * as request from…
user1283776
  • 19,640
  • 49
  • 136
  • 276
3
votes
3 answers

Bearer Authentication in React

How can I use Bearer Authentication with superagent in React? I am not sure in syntax and can't find an example. What I do now showTransactionList = () => { superagent …
3
votes
1 answer

How can I clear cookies between every test using Jest and Supertest?

I have a suite of tests that all pass if they are run individually. However, the tests fail due to a check on the value of a cookie if they are run in parallel. The problem is that supertest's cookies are not cleared between each test. Is there a…
YPCrumble
  • 26,610
  • 23
  • 107
  • 172
3
votes
1 answer

What is the proper type for Angular DI injected superagent?

I'm trying to inject Superagent in a node.js app which users Angular DI (ngx). import * as request from 'superagent'; ... { provide: request, useFactory: () => request.agent() .timeout({deadline: 10000, timeout: 60000}), …
FlavorScape
  • 13,301
  • 12
  • 75
  • 117
3
votes
1 answer

How to avoid superagent: double callback bug

I make simple get request using supertest. Response might be an image. Supertest - v3.0.0 SuperAgent - v3.8.2 Node - carbon (8.9.4) After all these upgrades, I encountered the following code: const request = require('supertest'); it('mocha test',…
3
votes
1 answer

AWS lambda error making node https request

I've written an AWS lambda that makes an https request to an endpoint that triggers a reset password email. When I run my lambda locally, all runs as expected and I get the email in my inbox, however, when I upload my node code and run the lambda…
deanmau5
  • 861
  • 7
  • 17
  • 27
3
votes
1 answer

superagent dynamic method types

I'm using superagent and I faced a problem with dynamic method name. For every method I shoud write: request .get(url) request .post(url) Is there any way to pass method name as parameter to superagent like that done in axios axios({ …
ivankoleda
  • 340
  • 1
  • 11
3
votes
1 answer

Getting async/await to work with superagent

I'm missing something in my syntax here but not sure what: I'm trying to nock this. But I get expected undefined to equal 'pXVCJ9.eyJpYXQ' Test.js describe('User API', () => { let email, password, requestBody beforeEach(() => { email…
PositiveGuy
  • 17,621
  • 26
  • 79
  • 138
3
votes
0 answers

how to make post call using superagent

I am using following code to make an Post call using superagent process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; var request = require( "superagent" ); var PostUrl = 'http://example.com/rest/api/someapi'; var body = ["true"]; var data =…
Vishwanath Rawat
  • 497
  • 1
  • 6
  • 11
3
votes
2 answers

Pipe superagent response to express response

I'm trying to "proxy" some file with an express app. Why the code below doesn't work? var app = require('express')() var request = require('superagent') app.get('/image', function(req, res, next) { …
kharandziuk
  • 12,020
  • 17
  • 63
  • 121
3
votes
1 answer

Multer upload file + JSON object

Is it possible to send additionally to the file and json object containing data with multer? I found this thread. But it only explains how to attach one field at the time. Here what i have currently on client side: request .post(uploadPOSTUrl) …
Daniel Storch
  • 979
  • 3
  • 10
  • 25
3
votes
1 answer

How to look up request's text to debug using superagent?

I'm getting 400 code back from the server, so I need to check what's wrong with my request. How to print the request's raw text? That's my code right now: request.post('/api/events/') .send(preparedEvent) .end((err, res) => { if(!err){ …
3
votes
2 answers

How to mock external service when testing a NodeJS API

I have JSON API built with koa which I am trying to cover with integration tests. A simple test would look like this: describe("GET: /users", function() { it ("should respond", function (done) { request(server) …
silkAdmin
  • 4,640
  • 10
  • 52
  • 83
3
votes
0 answers

Can I force buffering of response bodies on the client (web browser)

I am running the following code on an express server and find my terminal prints an object with properties and values. However after this code is transpiled and run in a web browser I observe buffer of undefined. On the server, response.body is an…