0

The problem is while sending the test SMS I receive an error in the first line of the code and the error is require(...) is not a function: The code is given below:

const messagebird = require('messagebird')('<YOUR_ACCESS_KEY');

var messageOptions= {
  'originator': 'Message',
  'recipients': [
    'phonenumber'
],
  'body': 'This is a test message'
};



 messagebird.messages.create(messageOptions, function (err, response) {
      if (err) {
        return console.log(err);
      }
      console.log(response);
    });

1 Answers1

0

You need to update your code to init MB client like this:

const messagebird = require('messagebird').initClient('<YOUR_ACCESS_KEY>');

Or with ES6 syntax:

import { initClient } from 'messagebird';
const messagebird = initClient('<YOUR_ACCESS_KEY>');

Hope that helps.

NIBERIUM
  • 76
  • 6