sendgrid-nodejs icon indicating copy to clipboard operation
sendgrid-nodejs copied to clipboard

TypeError: Object #<Header> has no method 'toJsonString'

Open ArkeologeN opened this issue 12 years ago • 10 comments

I just re-installed all of my modules from dependencies and sendgrid is now throwing errors. Not sure why is that?

(function() {
    var config = require('./config')()
        , sendgrid = require('sendgrid')(config.sendgrid.username, config.sendgrid.password)
        , email;
// Also tried: sendgrid = require('sendgrid')(config.sendgrid.username, config.sendgrid.password, {api: config.sendgrid.api})

    sendgrid.send({
        to:       '[email protected]',
        from:     '[email protected]',
        subject:  'Account Activation',
        text:     'Banana Song?'
    }, function(err, msg) {
        console.log(arguments);
    })
})();

but everytime it throws:

TypeError: Object #<Header> has no method 'toJsonString'

Before digging, I thought to post the issue if that's already fixed or in pipe! Thanks!

ArkeologeN avatar Jan 09 '14 20:01 ArkeologeN

See the solution in #113

rm -rf node_modules
npm install

brandonmwest avatar Jan 09 '14 20:01 brandonmwest

@brandonmwest I still can't find it working as its still a bit of old copy.

// Line: 131
'x-smtpapi' : this.smtpapi.toJsonString(),

Re-building the modules (by running npm install) and even npm update the job. Can you please verify if it's updated over npmjs ?

ArkeologeN avatar Jan 09 '14 21:01 ArkeologeN

Well that's weird. npm is updated. @scottmotte any ideas?

brandonmwest avatar Jan 09 '14 21:01 brandonmwest

Looking now.

motdotla avatar Jan 09 '14 21:01 motdotla

@ArkeologeN @brandonmwest

So I just created a new project with this:

{
  "name": "Test",
  "description": "test_node",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "sendgrid": "1.0.0-rc.1.0"
  }
}

And I'm seeing this:

// Line 140
'x-smtpapi' : this.smtpapi.jsonString(),

So on a fresh npm install it works, might be an issue with npm update: @ArkeologeN can you post your package.json up and confirm that you did a rm -rf node_modules && npm install?

siyegen avatar Jan 09 '14 21:01 siyegen

@ArkeologeN yep, what @siyegen said. I also just did a test using: https://github.com/scottmotte/sendgrid-nodejs-example

@ArkeologeN if you'd prefer to email your package.json, please do to me at [email protected]

motdotla avatar Jan 09 '14 21:01 motdotla

@scottmotte hey it works after changing from "sendgrid" : "*" to "sendgrid": "1.0.0-rc.1.0".

However, the npm is still showing old revision here: Sendgid

ArkeologeN avatar Jan 10 '14 10:01 ArkeologeN

Ok, cool.

@ArkeologeN so npm will always have the old versions. It maintains the old versions so that people can still use older versions if they'd like.

1.0.0-rc.1.0 is the newest (but BETA Release Candidate).

0.4.6 is the newest STABLE

motdotla avatar Jan 10 '14 20:01 motdotla

Right, thanks!

ArkeologeN avatar Jan 11 '14 08:01 ArkeologeN

Issue is still present in latest version on npm (1.0.0-rc.1.0) I got around it by changing "sendgrid" : "*" to "sendgrid": "0.4.6" in the package.json.

quentinadam avatar Feb 06 '14 12:02 quentinadam