Edits history of script submission #11183 for ' Show content data export (intercom)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Intercom = {
    	apiVersion: string
    	token: string
    }
    /**
     * Show content data export
     * You can view the status of your job by sending a `GET` request to the URL
    `https://api.
     */
    export async function main(auth: Intercom, job_identifier: string) {
    	const url = new URL(`https://api.intercom.io/export/content/data/${job_identifier}`)
    
    	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