1
Get a properties configuration from hubspot crm
One script reply has been approved by the moderators Verified
Created by sindre svendby964 343 days ago Viewed 4033 times
0
Submitted by sindre svendby964 Deno
Verified 343 days ago
1
// Ctrl+. to cache dependencies on imports hover, Ctrl+S to format.
2

3
type Hubspot = {
4
  token: string;
5
};
6
export async function main(
7
  auth: Hubspot,
8
  objectType: string,
9
  propertyName: string,
10
) {
11
  const res = await fetch(
12
    `https://api.hubapi.com/crm/v3/properties/${objectType}/${propertyName}?archived=false`,
13
    {
14
      headers: {
15
        Authorization: `Bearer ${auth.token}`,
16
        Accept: "application/json",
17
      },
18
      method: "GET",
19
    },
20
  );
21
  const jsonRes = await res.json();
22
  if (jsonRes.status == "error") {
23
    console.error(jsonRes);
24
    throw new Error(jsonRes.message);
25
  }
26
  return jsonRes;
27
}
28