By passing in the appropriate options,
by hugo697 ยท 12/20/2024
1
//native
2
type Xero = {
3
token: string
4
}
5
/**
6
* Retrieves a specific file associations
7
* By passing in the appropriate options,
8
9
*/
10
export async function main(auth: Xero, FileId: string, xero_tenant_id: string) {
11
const url = new URL(`https://api.xero.com/files.xro/1.0//Files/${FileId}/Associations`)
12
13
const response = await fetch(url, {
14
method: 'GET',
15
headers: {
16
Accept: 'application/json',
17
'xero-tenant-id': xero_tenant_id,
18
Authorization: 'Bearer ' + auth.token
19
},
20
body: undefined
21
})
22
if (!response.ok) {
23
const text = await response.text()
24
throw new Error(`${response.status} ${text}`)
25
26
return await response.json()
27
28