//native
type Ynab = {
token: string
}
export async function main(
auth: Ynab,
budget_id: string,
month: string,
category_id: string,
body: { category: { budgeted: number } }
) {
const url = new URL(
`https://api.ynab.com/v1/budgets/${budget_id}/months/${month}/categories/${category_id}`
)
const response = await fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
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 581 days ago