Questions tagged [superagent]

410 questions
2
votes
0 answers

IE XHR: jQuery.ajax vs TJ's superagent

I noticed TJ Holowaychuk's superagent library ("Ajax with less suck") try's several ActiveXObject methods for IE when generating a cross browser XHR object: // ...if normal browser: return new XMLHttpRequest; } else { try { return new…
Devin Rhode
  • 23,026
  • 8
  • 58
  • 72
1
vote
1 answer

Testing Node with Superagent and Mocha

when I run this code below, the user is logged in and the browser is redirected to a new route home. How do I structure the test below to validate that /home is being redirected to. The application is working fine, I am just trying to get my test…
Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80
1
vote
0 answers

superagent handle compressed json response

I have a simple superagent get request, but want to use compression for transfer, as the jsons are quite large. The response, by looking at the network log is a stream, but superagent is not decoding it. Did not find clues on google why. Request,…
Miro Krsjak
  • 355
  • 1
  • 16
1
vote
0 answers

Superagent is causing localhost to not connect

Every time I use npm install superagent my localhost no longer works. Instead, the terminal asks if I want to run the app on another port ("Would you like to run the app on another port instead? (Y/n)"). No matter my response, the localhost will not…
1
vote
0 answers

NestJS CORS blocking localhost

I am trying to enable CORS to connect my nestJS API with a local react app. But it seems that CORS is blocking access from the React App. I've tries this so far: First attempt: async function bootstrap() { const app = await…
1
vote
1 answer

post request using superagent

I have been trying to make a post request to the pokeapi using superagent request lib. I am not sure why the request is not successful. Below is my code. I am fairly new to superagent, so any advice will be appreciated. try { const pokemon =…
Xavier
  • 55
  • 10
1
vote
1 answer

Inclusion of header causes requests to not be send

I have react application where I want to add a request-id header to my requests, such that the frontend can tell the backend to undo a specific request. So requests (using superagent) are something like this: let result = request(method,…
Peter Mølgaard Pallesen
  • 1,470
  • 1
  • 15
  • 26
1
vote
0 answers

How do I send payload in superagent

I am not sure how to send payload using superagent, does anyone know that can reply with how to do it under here? my guess would be: .payload({ "key": "value" "key2": "value2" }) Please Help! :)
Salvatore Timpani
  • 407
  • 3
  • 6
  • 26
1
vote
0 answers

How to increase the frequency of useragent’s progress event?

By default, the progress event is only fired once a second. import request from "superagent" const req = request.post("https://example.net") // files.forEach((file) => { // req.attach(file.name, file) // }) req.on("progress", (event) => { …
sunknudsen
  • 6,356
  • 3
  • 39
  • 76
1
vote
1 answer

How to add headers in superagent GET request

Here is a basic code: const superagent = require('superagent'); superagent.get('https://api.arabam.com/pp/step') .query({ apikey: '_V85Kref7xGZHc1XRpUmOhDDd07zhZTOvUSIbJe_sSNHSDV79EjODA==' }) .end((err, res) => { if (err) { return…
Amna Arshad
  • 767
  • 3
  • 10
  • 21
1
vote
1 answer

How to read an attachement from res of supertest?

I have an express end point "/api/posts/:id" that returns some metadata about a post and the post file itself through res.attachment(post.fileName).send(post). (Note I'm not sure if this is correct) I'm trying to test it using supertest. After…
Omar
  • 23
  • 3
1
vote
1 answer

Node JS returns undefined within async json call

I have an asynchronous function that is called when the api is connected to. this should return some json and then it will be displayed on the json response of the page. In the json response I get undefined. This is the code i am using: const…
Luke Acko13
  • 61
  • 2
  • 9
1
vote
1 answer

Superagent response body undefined until next line

I am testing my express API using Jest and Supertest. For some reason this does not work: const id = await request.post('/program') .send(body) .expect('Content-Type', /json/) .expect(201).body.id; It fails with error: TypeError: Cannot…
stelioslogothetis
  • 9,371
  • 3
  • 28
  • 53
1
vote
0 answers

When I use SuperAgent & Koa patch and send the data, the error is thrown

I need to use Koa and SuperAgent to patch something I need. But when I run my project, the error is thrown. The code const Koa = require('koa'); // const request = require('request') const superagent= require('superagent'); const app = new…
Mathon
  • 13
  • 3
1
vote
1 answer

How to run test with local.example.js ENV

I have 2 env: dev local.example.js enter image description here i run test with this command "mocha specs/* --opts ./mocha.opts" and default run dev ENV. What command I can use for a run with local.example.js ENV ? Like "mocha specs/* --opts…