//native
type Leonardoai = {
apiKey: string;
};
/**
* Get 3D Model by ID
* This endpoint gets the specific 3D model
*/
export async function main(
auth: Leonardoai,
id: string,
offset: string | undefined,
limit: string | undefined,
body: { id?: string },
) {
const url = new URL(`https://cloud.leonardo.ai/api/rest/v1/models-3d/${id}`);
for (const [k, v] of [
["offset", offset],
["limit", limit],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
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 428 days ago