Edits history of script submission #8985 for ' Get Record (contentful)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import Contentful from 'contentful-management'
    
    type Contentful = {
    	accessToken: string
    	environment: string
    	spaceId: string
    }
    
    const makeClient = (resource: Contentful) => {
    	return Contentful.createClient(
    		{ accessToken: resource.accessToken },
    		{
    			type: 'plain',
    			defaults: { spaceId: resource.spaceId, environmentId: resource.environment }
    		}
    	)
    }
    
    export async function main(resource: Contentful, entryId: string) {
    	const client = makeClient(resource)
    
    	const response = await client.entry.get({
    		entryId
    	})
    
    	return response
    }
    

    Submitted by hugo697 650 days ago