TypeError: superagent.auth is not a function, x is not a function

446 Views Asked by At

im literally just following the code on this site but I am having this error, not sure why

https://developers.telnyx.com/docs/v2/messaging/twexit?lang=python&fbclid=IwAR08WBnG4cLSbcRVneMpui0V02W90oCAExCbNb6ICJrQa6dgkkv_kzxsA-o

// https://github.com/visionmedia/superagent#install
const superagent = require('superagent');

superagent
  .auth('my strings')
  .post(`https://api.telnyx.com/2010-04-01/Accounts/my string/Messages.json`)
  .send({
    From: '', // Your Telnyx number
    To: '',
    Body: "Is this working, World!"
  })
  .then((response) => {
    console.log(response.body);
  });

note: i just wrote my strings in place of the actual code for privacy

1

There are 1 best solutions below

1
traynor On

method comes first, reverse it: ...post().auth()...:

// https://github.com/visionmedia/superagent#install
const superagent = require('superagent');

superagent
  .post(`https://api.telnyx.com/2010-04-01/Accounts/my string/Messages.json`)
  .auth('my strings')
  .send({
    From: '', // Your Telnyx number
    To: '',
    Body: "Is this working, World!"
  })
  .then((response) => {
    console.log(response.body);
  });