INNER CODE UNIT · TypeScript
handleApiCall
gobii-ai/gobii-platform · misc/ts-example-client/src/index.ts:43
async function handleApiCall<T>(
operationName: string,
apiCall: () => Promise<T>
): Promise<T | null> {
console.log(`--- Running: ${operationName} ---`);
try {
const result = await apiCall();
console.log('API Call Successful.');
console.log(`Result:\n${prettyPrintJson(result)}`);
return result;
} catch (error: any) {
console.error(`Error during ${operationName}:`);
if (error.response) {
console.error(` Status: ${error.response.status}`);
console.error(` Status Text: ${error.response.statusText}`);