Questions tagged [superagent]

We currently don't have any instructions on how to use this tag just yet.

Loop through an array of objects, then store each one in MongoDB

If I receive an Array of Objects from a Facebook endpoint, how can I save each Object into my MongoDB? What is the best way to iterate over the returned Array and then store it in my mongoDB? :) The code snippet below shows how I fetch data from the Face ...

Tips for preventing the need to create a function within a loop

Currently, I am in the process of collecting data through REST calls. I have created a function that accesses a "directory" endpoint to retrieve a list of individuals. While I can easily obtain details about their children, I need to make individual AP ...

What is the best way to implement the .retry function of superagent in a React.js application

I'm reaching out here because I have not been able to find clear examples or documentation on this topic. The official Supergent documentation only provides the following information: This method has two optional arguments: number of retries (default 3) ...

Encountering a Forbidden Error with Superagent

Here is the content of my index.js file I am attempting to fetch a response from a sports data API. I can successfully send curl requests to it, but when trying this method, I encounter a 403 forbidden error. var express = require('express'); var config ...

A guide to effectively mocking functions during testing using jest and superagent

I've encountered an issue where I can't mock files and functions that are utilized in the API call handler. The API call is being simulated with superagent. Below is the test code: // users.itest.js const request = require('superagent&apos ...

Ensure that agent.auth is executed prior to every test within a describe block

The following code is functioning correctly: describe('My App', function() { describe('when logged in', function() { it('should allow registered user to make a thing', function(done) { agent.post('/make-a-thing') .auth('testusername', 'v ...

Using Superagent in React: Executing a function within a callback

How can I call a function at the end of a request using Superagent to get the response? request.post('/TextUpload') .send({title:this.state.title1}) .end( function(res){ console.log(res); this.myFunction(); }) I keep receiving the error m ...

receiving incorrect request rather than the complete error message

Handling errors when using POST with the same user email can be achieved using the following code snippet (utilizing superagent): export function signUpUser(userData) { return async dispatch => { try { const currentUser = await request.pos ...

"The value of res.text is not defined for this SuperAgent request

Recently, I decided to try out a TDD approach using Mocha and SuperAgent. However, I encountered a problem when the res.text from SuperAgent turned out to be undefined. Check out the test below: it('should return 2 when the url is /add/1/1', function(don ...