你能帮我解决我的代码中的错误吗?我正在尝试将 Mailchimp 连接到我的应用程序,以便当用户订阅电子邮件时,它会直接添加到 Mailchimp 中的“受众”中。我已经编写了代码,但代码抱怨“选项”对象。
import { request } from "http";
import { resolve } from "url";
import { response } from "express";
import { reject } from "lodash";
export async function keepSubscribers(email: string) {
const data = {
members: [
{
// eslint-disable-next-line @typescript-eslint/camelcase
email_address: email,
status: 'subscribed'
}
]
}
const postData = JSON.stringify(data)
const options = {
url: 'https://us20.api.mailchimp.com/3.0/lists/b0404295b1',
method: 'POST',
headers: {
Authorization: 'auth 71634e399a09a918610fd25094e6731c-us20'
},
body: postData
}
return new Promise((resolve, reject) => {
request(options: Object, (err: Object, response: { statusCode: number }) => {
if (err) {
return reject(`Request cannot be processed`);
} else {
if (response.statusCode === 200) {
return resolve(true)
} else {
return reject(`Request cannot be processed`);
}
}
})
})
}