0
Get Contacts Job Status
One script reply has been approved by the moderators Verified
Created by adam186 751 days ago Viewed 9284 times
0
Submitted by adam186 Deno
Verified 751 days ago
1
import sendgrid from "npm:@sendgrid/client@^7.7.0";
2

3
type Sendgrid = {
4
  token: string;
5
};
6
export async function main(api_token: Sendgrid, job_id: string) {
7
  sendgrid.setApiKey(api_token.token);
8

9
  const request = {
10
    url: `/v3/marketing/contacts/imports/${job_id}`,
11
    method: "GET",
12
  };
13

14
  try {
15
    const [_, body] = await sendgrid.request(request);
16
    return body;
17
  } catch (error) {
18
    throw Error("\n" + JSON.stringify(error?.response?.body || error));
19
  }
20
}
21