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

TypeError: Object # has no method 'toJsonString'

Open nquinlan opened this issue 12 years ago • 4 comments

From GetSatisfaction:http://community.sendgrid.com/sendgrid/topics/typeerror_object_has_no_method_tojsonstring

I'm using the sendgrid node module. My coworker's machine runs everything fine. All our files are the same as we use git for version control. We have both done npm update: current version of sendgrid module is 1.0.0-rc.1.0. I also sometimes get a 'wrong credentials' error with this error, the credentials are correct so that is a false error.

Stack trace: 
TypeError: Object # has no method 'toJsonString' 
at Email.toWebFormat (/project/node_modules/sendgrid/lib/email.js:131:32) 
at _send (/project/node_modules/sendgrid/lib/sendgrid.js:67:31) 
at send (/project/node_modules/sendgrid/lib/sendgrid.js:31:21) 
at Object.exports.sendVerifyEmail (/project/utilities/emailer.js:16:11) 
at exports.email (/project/routes/index.js:156:43) 
at callbacks (/project/node_modules/express/lib/router/index.js:164:37) 
at param (/project/node_modules/express/lib/router/index.js:138:11) 
at param (/project/node_modules/express/lib/router/index.js:135:11) 
at pass (/project/node_modules/express/lib/router/index.js:145:5) 
at Router._dispatch (/project/node_modules/express/lib/router/index.js:173:5)

This may better be attached to sendgrid/smtpapi-nodejs. @scottmotte please advise.

nquinlan avatar Jan 07 '14 21:01 nquinlan

Looks like this commit e5ca93d changed toJsonString -> jsonString

 Email.prototype.addFile = function(file_object) {
@@ -128,7 +137,7 @@ Email.prototype.toWebFormat = function() {
   var web  = {
     to          : this.to,
     from        : this.from,
-    'x-smtpapi' : this.smtpapi.toJsonString(),
+    'x-smtpapi' : this.smtpapi.jsonString(),
     subject     : this.subject,
     text        : this.text,
     html        : this.html,

So looks like he (somehow) has old code while his coworker does not. Though I thought npm update would have taken care of that? @scottmotte

siyegen avatar Jan 09 '14 08:01 siyegen

Yeah, npm should have. Looking into this.

I'm 90% sure npm update should have worked, but possibly because I did a force push on this npm publish -f, it messed up his install.

He will need to remove node_modules and run npm install again.

rm -rf node_modules
npm install

motdotla avatar Jan 09 '14 16:01 motdotla

@nquinlan I updated the GetSatisfaction.

motdotla avatar Jan 09 '14 16:01 motdotla

Awesome! Thanks Scotty!

nquinlan avatar Jan 09 '14 18:01 nquinlan