//native
const graph = "https://graph.microsoft.com/v1.0"
/**
* Get Site
* Get a SharePoint site by id, or by address as `<hostname>:/<server-relative path>` (e.g. `contoso.sharepoint.com:/sites/Marketing`); `root` is the tenant's root site. A direct lookup, so it finds sites the search index does not have yet. Requires Sites.Read.All (covered by the default Sites.ReadWrite.All).
*/
export async function main(
auth: RT.MsSharepoint,
site_id: string,
select: string | undefined
) {
const url = new URL(`${graph}/sites/${site_id}`)
if (select != null && select !== "") {
url.searchParams.append("$select", select)
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 hours ago