Use NPM Package w/ Meteor? Wrapping Question

I’m trying unsuccessfully to use a NPM package with Meteor.

I’m currently using meteor add meteorhacks:async and am trying to adapt the example of the atmosphere page (https://atmospherejs.com/meteorhacks/async) to my own usage .

After including the right package version in the packages.json file here is what I have:

var URL = Meteor.npmRequire('url2png')('PE73CXXXXXX','S_0561FXXXXXX');

  var options = {
    viewport : '900x600',
    thumbnail_max_width : 400,
    protocol: 'http'
  }


var a = Meteor.wrapAsync(URL.buildURL, URL);
var url = a('google.com' , options)

When I run this it doesn’t throw any errors and acts as if it never exited the callback loop.

Here is the NodeJS code I am trying to adapt:

// See also
// https://www.npmjs.com/package/url2png

var url2png = require('url2png')('API_KEY', 'PRIVATE_KEY');
 
var options = {
  viewport : '900x600',
  thumbnail_max_width : 400,
  protocol: 'http'
}
 
//Get the URL 
var url = url2png.buildURL('google.com' options);

Any suggestions to point me in the right direction?

It seems like you can use var url = url2png.buildURL('google.com' options); directly. It doesn’t accept a callback.

So, you don’t need to use Meteor.wrapAsync

1 Like

Thank you very much! Your solution worked perfectly! You rock!