Edits history of script submission #13929 for ' List table columns (xata)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Xata = {
    	apiKey: string
    	workspaceUrl: string
    }
    /**
     * List table columns
     * Retrieves the list of table columns and their definition. This endpoint returns the column list with object columns being reported with their
    full dot-separated path (flattened).
    
     */
    export async function main(auth: Xata, db_branch_name: string, table_name: string) {
    	const url = new URL(`${auth.workspaceUrl}/db/${db_branch_name}/tables/${table_name}/columns`)
    
    	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