type Convertkit = {
apiSecret: string
}
export async function main(resource: Convertkit, subscriberId: string) {
// Construct the query parameters.
const queryParams = new URLSearchParams({
api_secret: resource.apiSecret
})
const endpoint = `https://api.convertkit.com/v3/subscribers/${subscriberId}?${queryParams.toString()}`
const response = await fetch(endpoint, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
return data.subscriber
}
Submitted by hugo697 79 days ago