ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.58k stars 1.33k forks source link

Equivalent of https.agent #1810

Open Shahanshah-TA opened 1 month ago

Shahanshah-TA commented 1 month ago

Describe the bug

Node.js version: 21.6.2

OS version: MacOS sonoma 14.5

Description: Hi I need to send certificate in api request, so I was trying with axios but new https.agent({}) is not supported by React Native as it is a Node API. Is there any way I can use this package to fix this issue?

Actual behavior

Getting error This is not supported in browser version of superagent

Expected behavior

It should complete the request.

Code to reproduce

try {
    superagent
      .put(
        `myURL`,
      )
      .send({registrationId: registrationId}) // sends a JSON post body
      .set('Content-Type', 'application/json')
      .set('Content-Encoding', 'utf-8')
      .agent({
        cert: cert,
        key: key,
      })
      .end((err, res) => {
        if (err) {
          console.log('err', err);
        } else {
          console.log('res', res);
        }
        // Calling the end function will send the request
      });
  } catch (err) {
    console.log('err', err);
  }

Checklist