Get A Contact List ( sendgrid)
One script reply has been approved by the moderators Verified

Created by adam186 117 days ago Viewed 53 times 0 Points

No comments yet

Login to be able to comment
Points: 0
deno
One script reply has been approved by the moderators
Ap­pro­ved
import * as wmill from "https://deno.land/x/windmill@v1.70.1/mod.ts"
import sendgrid from "npm:@sendgrid/client@^7.7.0"

/**
 * @param contact_sample If `true` then `contact_sample` will be returned with the result.
 */
export async function main(
  api_token: wmill.Resource<"sendgrid">,
  list_id: string,
  contact_sample?: boolean,
) {
  sendgrid.setApiKey(api_token.token)

  const request = {
  url: `/v3/marketing/lists/${list_id}`,
  method: 'GET',
  qs: {
    contact_sample
  }
}

  try {
    const [_, body] = await sendgrid.request(request)
    return body
  } catch (error) {
    throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
  }
}

Submitted by adam186 117 days ago

Edited 29 days ago

No comments yet

Login to be able to comment