Could you help me with the error in my code. I am trying to connect Mailchimp to my app, so that when a user subscribes with an email, it is directly added to "audience" in Mailchimp. I have written the code, but the code is complaining about "options" object.
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`);
}
}
})
})
}