0
Get Opportunity
One script reply has been approved by the moderators Verified

Gets a specific opportunity in Apollo.io. See the documentation

Created by hugo697 25 days ago Viewed 10 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 25 days ago
1
type Apollo = {
2
  apiKey: string;
3
};
4

5
export async function main(resource: Apollo, opportunityId: string) {
6
  const endpoint = `https://api.apollo.io/v1/opportunities/${opportunityId}`;
7

8
  const response = await fetch(endpoint, {
9
    method: "GET",
10
    headers: {
11
      "Content-Type": "application/json",
12
      "Cache-Control": "no-cache",
13
      "X-Api-Key": resource.apiKey,
14
    },
15
  });
16

17
  if (!response.ok) {
18
    throw new Error(`HTTP error! status: ${response.status}`);
19
  }
20

21
  const data = await response.json();
22

23
  return data.opportunity;
24
}
25