Returns data for a single subscriber
1
type Convertkit = {
2
apiSecret: string
3
}
4
5
export async function main(resource: Convertkit, subscriberId: string) {
6
// Construct the query parameters.
7
const queryParams = new URLSearchParams({
8
api_secret: resource.apiSecret
9
})
10
11
const endpoint = `https://api.convertkit.com/v3/subscribers/${subscriberId}?${queryParams.toString()}`
12
13
const response = await fetch(endpoint, {
14
method: 'GET',
15
headers: {
16
'Content-Type': 'application/json'
17
18
19
20
if (!response.ok) {
21
throw new Error(`HTTP error! status: ${response.status}`)
22
23
24
const data = await response.json()
25
26
return data.subscriber
27
28