More info: https://developers.hubspot.com/docs/api/crm/properties
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