//native
type Brex = {
token: string;
};
/**
* Update an expense
* Update an expense. Admin and bookkeeper have access to any expense, and regular users can only access their own.
*/
export async function main(
auth: Brex,
expense_id: string,
body: { memo?: string },
) {
const url = new URL(
`https://platform.brexapis.com/v1/expenses/card/${expense_id}`,
);
const response = await fetch(url, {
method: "PUT",
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 217 days ago