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

Gets the profile of the current authenticated member. See the docs here

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

6
export async function main(resource: Linkedin) {
7
	const endpoint = 'https://api.linkedin.com/rest/me'
8

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

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

22
	const data = await response.json()
23

24
	return data
25
}
26