Monday, 13 March 2017

Firebase functions - getaddrinfo ENOTFOUND api.sandbox.paypal.com

trying to make a request to paypal's API using PayPal-node-SDK

exports.requestPayment = functions.https.onRequest((req, res) => {
    return new Promise(function (fullfilled, rejected) {
        paypal.payment.create(create_payment_json, {}, function (error, payment) {
            if (error) {
                rejected(error);
            } else {
                console.log("Create Payment Response");
                console.log(payment);
                res.status(200).send(JSON.stringify({
                    paymentID: payment.id
                })).end();
                fullfilled(payment);
            }
        });
     });
});

but i'm constantly getting an error:

Error: getaddrinfo ENOTFOUND api.sandbox.paypal.com api.sandbox.paypal.com:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

Things iv'e tried:

  1. making a request to a totally different host, still ENOTFOUND
  2. wrapping the request with cors(req,res, ()=>{...})
  3. prepending https:// to the host

What is the problem ?



via user47376

No comments:

Post a Comment