尝试使用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)
我尝试过以下方法:
- 向完全不同的主机发出请求,仍然出现
ENOTFOUND
错误。 - 使用
cors(req, res, ()=>{...})
包装请求。 - 在主机前面添加
https://
。
问题是什么?
https://us-central1-joanne-lee.cloudfunctions.net/getUrls/portrait
时,我遇到了getaddrinfo ENOTFOUND
错误。 - bob