1

I have a meteor method where I am using the easy post api. Below is some asyncronous code which I expect to give an error from the EasyPost api (because it is an invalid address).

EasyPost = Easypost("<you don't get to see my api key>");
EasyPost.Address.create_and_verify(address, function (err, response) {
  console.log(err);
});

This gives me the following response, which is what I expect.

{
  message: {
    code: "ADDRESS.VERIFY.FAILURE",
    message: "Address Not Found",
    errors: []
  },
  param: undefined
}

I want to try and make this syncronous, so I tried the following, but my meteor shell always logs [Object object]

> var createAndVerifySync = Meteor.wrapAsync(EasyPost.Address.create_and_verify, EasyPost.Address);
> createAndVerifySync(address);
[object Object]

I suspect this has to do with the error message from EasyPost returning as an object. How could I create a wrapper around the asyncronous methods of EasyPost with the inclusion of Meteor and futures?

KFunk
  • 2,956
  • 22
  • 33
corvid
  • 10,733
  • 11
  • 61
  • 130
  • 2
    See this post, which is all about the problems with returning errors from Meteor.wrapAsync. http://stackoverflow.com/questions/26226583/meteor-proper-use-of-meteor-wrapasync-on-server/29602309#29602309 There's an open bug, and I ended up using a bit of a hack. – mwarren May 21 '15 at 21:13
  • If my answer was useful, it would be great if you would go back to the question in the link and upvote my answer! Thanks. – mwarren May 22 '15 at 17:12

1 Answers1

0

For future travelers, this was answered via this comments by @mwarren on this question.

Justin Hammond
  • 595
  • 8
  • 20