//native
/**
* Retrieve user profile info for a given user ID
* Fetches relevant profile info such as first & last name, birth date etc. for a given user ID
*/
export async function main(
auth: RT.Terra,
user_id: string | undefined,
to_webhook?: string | undefined
) {
const url = new URL(`https://api.tryterra.co/v2/athlete`)
for (const [k, v] of [
['user_id', user_id],
['to_webhook', to_webhook]
]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
'dev-id': auth.devId,
'X-api-key': auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago