Edits history of script submission #9095 for ' Retrieve Attributes (zixflow)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    type Zixflow = {
    	apiKey: string
    }
    
    export async function main(resource: Zixflow, target: 'collection' | 'list', targetId: string) {
    	const endpoint = `https://api.zixflow.com/api/v1/attributes/${target}/${targetId}`
    
    	const response = await fetch(endpoint, {
    		method: 'GET',
    		headers: {
    			Authorization: `Bearer ${resource.apiKey}`
    		}
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	const data = await response.json()
    
    	return data
    }
    

    Submitted by hugo697 607 days ago