Easypost - Nested Callback Issues


#1

###Easypost - Nested Callback - Async || wrapAsync

  • Currently having an issue running the following in production, when it works great on local. Any help or hints would be great. Thanks in advance.

#2

I am using the following example in https://github.com/EasyPost/easypost-node

easypost.Shipment.create({
to_address: toAddress,
from_address: fromAddress,
parcel: parcel,
customs_info: customsInfo
}, function(err, shipment) {
    // buy postage label with one of the rate objects
    shipment.buy({rate: shipment.lowestRate(['USPS', 'ups'])}, function(err, shipment) {
        console.log(shipment.tracking_code);
        console.log(shipment.postage_label.label_url);
    });
});

Currently my code looks like so

var easypost = Easypost("**************");
try{
                createShippingWrap = Meteor.wrapAsync(easypost.Shipment.create);
                result = createShippingWrap({
                    to_address:easy.toAddress,
                    from_address:easy.fromAddress,
                    parcel:parcel
                });
                console.log(result);
                // result.buy({rate:result.lowestRate(['USPS'],['Priority'])},
                // Meteor.bindEnvironment(function (err,shipment){
                //     ShipmentLabelAppended.insert({invoiceId:sess_id,label:shipment.postage_label.label_url});
                // }));
            }
            catch(error){
                console.log("error",JSON.stringify(error.stack));
            }
        }

And the following is an error


#3

The problem was on previous logic, nullify