"string"、"stdClass" 类型的预期参数给定错误

Expected argument of type "string", "stdClass" given Error

我正在为 nodejs 使用 mailchimp-api-v3。我目前正在尝试更新用户的标签,但有时会弹出此错误,我不知道这意味着什么。我四处搜索,但似乎没有很多开发人员遇到过它。

欢迎提出任何建议。

try {
await mailchimp.post('/lists/' + listIDUsers + '/members/' + crypto.createHash('md5').update(profileSnap.val().email.toLowerCase()).digest("hex") + '/tags', {
        tags: [{name: "traveler", status: "active"}]
    });
} catch (error) {
if (error.status === 404) {
await mailchimp.post('/lists/' + listIDUsers + '/members', {
            email_address: profileSnap.val().email,
            status: 'subscribed',
            merge_fields: {
                "FNAME": profileSnap.val().firstName,
                "LNAME": profileSnap.val().lastName,
                "UID": uid,
                "EMAIL": profileSnap.val().email
            },
            tags: [{name: "traveler", status: "active"}]
        });
    } else {
        console.log("Issue for: " + uid);
        console.log(error);
 }

错误:

Error: Expected argument of type "string", "stdClass" given
    at Request._callback (/srv/node_modules/mailchimp-api-v3/index.js:506:30)
    at Request.self.callback (/srv/node_modules/request/request.js:185:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/srv/node_modules/request/request.js:1161:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/srv/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)

好的,我决定继续联系 Mailchimp,因为这个问题已经好几天没有人回答了!他们回复我说我收到上述错误的原因是因为我试图在添加订阅者后立即为订阅者设置标签,所以系统无法成功添加标签,因为订阅者散列 ID 尚未安静创建。

所以我只需要下面一行代码让我的函数在设置标签之前等待 10 秒。

await new Promise(resolve => setTimeout(resolve, 10000));
await mailchimp.post('/lists/' + listIDUsers + '/members/' + crypto.createHash('md5').update(profileSnap.val().email.toLowerCase()).digest("hex") + '/tags', {
    tags: [{name: "traveler", status: "active"}]
});