Edits history of script submission #17844 for ' Get a single organization job template locale (phrase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Phrase = {
    	token: string
    	baseUrl: string
    }
    /**
     * Get a single organization job template locale
     * Get a single job template locale for a given organization job template.
     */
    export async function main(
    	auth: Phrase,
    	account_id: string,
    	job_template_id: string,
    	job_template_locale_id: string
    ) {
    	const url = new URL(
    		`${auth.baseUrl}/accounts/${account_id}/job_templates/${job_template_id}/locales/${job_template_locale_id}`
    	)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'ApiToken ' + 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 235 days ago