Sendgrid-nodejs: context.sg.emptyRequest is not a function with @sendgrid/contact-importer

Created on 29 Jan 2019  路  5Comments  路  Source: sendgrid/sendgrid-nodejs

Issue Summary

Pushing a contact to the contact importer instance throws the following error:

@sendgrid/contact-importer/src/importer.js:81
    const request = context.sg.emptyRequest();
                               ^

TypeError: context.sg.emptyRequest is not a function
    at Object._sendBatch (/home/burtonium/projects/sentriex/server/node_modules/@sendgrid/contact-importer/src/importer.js:81:32)
    at Timeout._onTimeout (/home/burtonium/projects/sentriex/server/node_modules/bottleneck/lib/Bottleneck.js:180:34)
    at listOnTimeout (timers.js:324:15)
    at processTimers (timers.js:268:5)

package.json:

  "dependencies": {
    "@sendgrid/client": "^6.3.0",
    "@sendgrid/contact-importer": "^6.2.1"
}

Steps to Reproduce

const Importer = require('@sendgrid/contact-importer');
const sg = require('@sendgrid/client');
sg.setApiKey(process.env.SENDGRID_API_KEY);
const importer = new Importer(sg);

importer.push({ email });
importer.on('success', (result, batch) => {
   console.log('success');
});
importer.on('drain', () => {
   console.log('drained');
});

What is going on here?

Technical details:

Node.js Version:v11.1.0

bug

Most helpful comment

@Burtonium @thinkingserious Experiencing the same issue. I see the source has been updated to use @sendgrid/[email protected] in ab147403ea613e16b2a6ed2eb6aaed2672615268, however, these changes have not been pushed to npm. Is it possible to release this update please?

All 5 comments

Hello @Burtonium,

I'm not sure what is going on here, I don't even see a call to the emptyRequest function here.

I'm adding this to our backlog as a bug to dig deeper. Thanks for reporting this!

With Best Regards,

Elmer

The npm version you install gives you a call to that function. I saw the discrepancy from what was installed in node_modules vs the code on github. Might be a versioning issue.

@Burtonium @thinkingserious Experiencing the same issue. I see the source has been updated to use @sendgrid/[email protected] in ab147403ea613e16b2a6ed2eb6aaed2672615268, however, these changes have not been pushed to npm. Is it possible to release this update please?

Installing the main Sendgrid NPM Package fixed this for me.
Here's the example code for using sg.emptyRequest with the sendgrid npm package

var sg = require('sendgrid')(process.env.SENGRID_API_KEY);

var request = sg.emptyRequest({
    method: 'GET',
    path: '/v3/scopes',
    body: {}
  });

sg.API(request, function(error, response) {
    console.log(response.statusCode)
    console.log(response.body)
    console.log(response.headers)
});

Changes included in the 6.4.0 release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielflippance picture danielflippance  路  4Comments

kiranshashiny picture kiranshashiny  路  4Comments

egges picture egges  路  3Comments

umarhussain15 picture umarhussain15  路  3Comments

agostonbonomi picture agostonbonomi  路  3Comments