Files
kittycad.ts/src/api/api-calls/get_api_call.ts
Kurt Hutten 0359b620d8 updating spec (#113)
* YOYO NEW API SPEC!

* updating gen files

* handle enums for examples

* fix tests

* allow hidden endpoints

* Generated new lib

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-01 10:07:07 +10:00

33 lines
893 B
TypeScript

import fetch from 'node-fetch';
import { ApiCallWithPrice_type, Error_type } from '../../models.js';
import { Client } from '../../client.js';
interface Get_api_call_params {
client?: Client;
id: string;
}
type Get_api_call_return = ApiCallWithPrice_type | Error_type;
export default async function get_api_call({
client,
id,
}: Get_api_call_params): Promise<Get_api_call_return> {
const url = `/api-calls/${id}`;
const urlBase = process?.env?.BASE_URL || 'https://api.kittycad.io';
const fullUrl = urlBase + url;
const kittycadToken = client
? client.token
: process.env.KITTYCAD_TOKEN || '';
const headers = {
Authorization: `Bearer ${kittycadToken}`,
};
const fetchOptions = {
method: 'GET',
headers,
};
const response = await fetch(fullUrl, fetchOptions);
const result = (await response.json()) as Get_api_call_return;
return result;
}