Get Contacts Job Status

Script sendgrid Verified

by adam186 ยท 12/2/2022

The script

Submitted by hugo989 Bun
Verified 3 days ago
1
import sendgrid from "@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

Other submissions
  • Submitted by adam186 Deno
    Created 395 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