Edits history of script submission #13350 for ' List all comments for a portout request (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * List all comments for a portout request
     * Returns a list of comments for a portout request.
     */
    export async function main(auth: Telnyx, id: string) {
    	const url = new URL(`https://api.telnyx.com/v2/portouts/${id}/comments`)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 428 days ago