小编典典

Firebase的云功能-getaddrinfo ENOTFOUND

node.js

尝试使用PayPal-node-SDK向Paypal的API请求

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);
            }
        });
     });
});

但我不断出错:

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)

我尝试过的事情:

  1. 向完全不同的主机发出请求 ENOTFOUND
  2. 将请求包装为 cors(req,res, ()=>{...})
  3. 预先考虑https://到主机

问题是什么?


阅读 290

收藏
2020-07-07

共1个答案

小编典典

您需要按照付费计划进行外部API请求。

Firebase的Blaze计划(随用随付)为云功能免费分配。https://firebase.google.com/pricing/

2020-07-07