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

Gets another member's profile, given its person id. See the docs here

Created by hugo697 133 days ago Viewed 61 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 133 days ago
1
type Linkedin = {
2
	token: string
3
	apiVersion: string
4
}
5

6
export async function main(resource: Linkedin, personId: string) {
7
	// This API will only return data for members who have not limited their off-LinkedIn visibility.
8
	const endpoint = `https://api.linkedin.com/rest/people/(id:${personId})`
9

10
	const response = await fetch(endpoint, {
11
		method: 'GET',
12
		headers: {
13
			Authorization: `Bearer ${resource.token}`,
14
			'LinkedIn-Version': `${resource.apiVersion}`,
15
			'X-Restli-Protocol-Version': '2.0.0'
16
		}
17
	})
18

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

23
	const data = await response.json()
24

25
	return data
26
}
27