thorning / node-mailchimp

node mailchimp wrapper using v3 of the mailchimp api
MIT License
288 stars 35 forks source link

post request for new list giving error every time #21

Closed mesozoic-technology closed 7 years ago

mesozoic-technology commented 7 years ago

The following code is constantly giving me this error:

/node_modules/mailchimp-api-v3/index.js:506
        reject(Object.assign(new Error(response.body.detail), response.body));
                      ^
TypeError: undefined is not a function 

Get requests for the root, and lists, are working fine. But this post request is giving problems. There does not seem to be anything unique about it, so I'm confused about the error... which seems to be an error when returning the error?

It's not something I am doing is it?

mailchimp.post('/lists',
  {
    name: 'dev_test',
    contact: {
      company: 'Rhino Inc.',
      address_1: 'Rhino',
      address_2: 'Rhino',
      city: 'Berkeley',
      state: 'CA',
      zip: '94704',
      country: 'US',
      phone: '1234567890'
    },
    permission_reminder: 'You are receiving this rhino.',
    use_archive_bar: false,
    campaign_defaults: {
      from_name: "rhino",
      from_email: "rhino@rhino.org",
      subject: 'test',
      language: 'english'
    },
    notify_on_suscribe: true,
    notify_on_unsubscribe: true,
    email_type_option: false,
    visibility: 'prv'
  }, function(err, result){
    console.log("ERR", err);
    console.log("RESULT", result);
});
mesozoic-technology commented 7 years ago

I inserted console logs into index.js and discovered I supplied a couple invalid parameters. But it should still return that error instead of erring on displaying the error

thorning commented 7 years ago

What version of node are you running?

mesozoic-technology commented 7 years ago

0.12.0

thorning commented 7 years ago

Object.assign is only available from v4 and later it seems. You can properly find a polyfill fairly easy (quick search found object-assign).