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

Gets a Contentful record for a given Content Model

Created by hugo697 26 days ago Viewed 10 times
0
Submitted by hugo697 Bun
Verified 26 days ago
1
import Contentful from 'contentful-management'
2

3
type Contentful = {
4
	accessToken: string
5
	environment: string
6
	spaceId: string
7
}
8

9
const makeClient = (resource: Contentful) => {
10
	return Contentful.createClient(
11
		{ accessToken: resource.accessToken },
12
		{
13
			type: 'plain',
14
			defaults: { spaceId: resource.spaceId, environmentId: resource.environment }
15
		}
16
	)
17
}
18

19
export async function main(resource: Contentful, entryId: string) {
20
	const client = makeClient(resource)
21

22
	const response = await client.entry.get({
23
		entryId
24
	})
25

26
	return response
27
}
28