//native
type Codat = {
encodedKey: string
}
/**
* Refresh all data
* Refreshes all data types with `fetch on first link` set to `true` for a given company.
This is an asynchronous operation, and will bring updated data into Codat from the linked integration for you to view.
[Read more](https://docs.codat.io/core-concepts/data-type-settings) about data type settings and `fetch on first link`.
*/
export async function main(auth: Codat, companyId: string) {
const url = new URL(`https://api.codat.io/companies/${companyId}/data/all`)
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Basic ${auth.encodedKey}`
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 235 days ago