//native
type Render = {
apiKey: string
}
/**
* Update environment variables
* Replace all environment variables for a service with the provided list of environment variables.
*/
export async function main(
auth: Render,
serviceId: string,
body: { key: string; value: string } | { key: string; generateValue: false | true }[]
) {
const url = new URL(`https://api.render.com/v1/services/${serviceId}/env-vars`)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago