Edits history of script submission #18480 for ' List total number of services for each environment of the project (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * List total number of services for each environment of the project
     * Returns a list of environment ids, and for each its total numberof services
     */
    export async function main(auth: RT.Qovery, projectId: string) {
    	const url = new URL(`https://api.qovery.com/project/${projectId}/environment/stats`)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Token ' + 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 235 days ago