Edits history of script submission #11124 for ' Find a specific tag (intercom)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Intercom = {
    	apiVersion: string
    	token: string
    }
    /**
     * Find a specific tag
     * You can fetch the details of tags that are on the workspace by their id.
    This will return a tag object.
    
     */
    export async function main(auth: Intercom, id: string) {
    	const url = new URL(`https://api.intercom.io/tags/${id}`)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			'Intercom-Version': auth.apiVersion,
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 536 days ago