[英]How to solve "Error: connect ECONNREFUSED" using mailchimp API
I'm trying to connect to the API mailchimp by using this code:我正在尝试使用以下代码连接到 API mailchimp:
const client = require('@mailchimp/mailchimp_marketing');
client.setConfig({
apiKey: "MY API KEY",
server: "MY SERVER",
});
async function run() {
const response = await client.ping.get();
console.log(response);
}
run();
In my code, I have the real API KEY and SERVER but I put fake one in here.在我的代码中,我有真正的 API KEY 和 SERVER,但我在这里放了假的。
After I run my main.js, I have this error that come and I don't know how to solve it:运行 main.js 后,出现此错误,但不知道如何解决:
(node:28092) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 72.9.105.30:443
(node:28092) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I have already install mailchimp by using:我已经使用以下方法安装了 mailchimp:
npm install mailchimp
But the error still come.但是错误还是来了。
npm install @mailchimp/mailchimp_marketing
check mailchimp_marketing documentation检查mailchimp_marketing 文档
const mailchimp = require('@mailchimp/mailchimp_marketing');
mailchimp.setConfig({
apiKey: 'YOUR_API_KEY',
server: 'YOUR_SERVER_PREFIX',
});
async function callPing() {
const response = await mailchimp.ping.get();
console.log(response);
}
callPing();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.