Skip to main content

utils

Documentation / lib/utils

logger​

const logger: Logger<never, boolean>;

Defined in: web-app/src/lib/utils.ts:11

Log errors in development and production environments.


callServerAPI()​

function callServerAPI(path: string, params?: any): Promise<any>;

Defined in: web-app/src/lib/utils.ts:45

Fetch data from server API by defining params in JSON and getting response in JSON, or return error JSON object.

Parameters​

ParameterTypeDescription

path

string

The path in the API to call

params?

any

Optional parameters to pass to the API

Returns​

Promise<any>

The response from the server API

Example​

var response: {
customField: string;
error: string;
} = await callServerAPI('users', {
method: 'POST',
headers: {
'X-API-KEY': 'your-api-key',
},
query: "search words",
})
if (response.error) {
console.error(response.error);
return;
}
console.log(response);

cn()​

function cn(...inputs: ClassValue[]): string;

Defined in: web-app/src/lib/utils.ts:90

Utility function for merging Tailwind classes, needed for shadcn-svelte.

Parameters​

ParameterTypeDescription

...inputs

ClassValue[]

Returns​

string

class name


getUserDeviceOS()​

function getUserDeviceOS(): "Windows" | "Mac" | "Linux" | "Android" | "iOS" | "Other";

Defined in: web-app/src/lib/utils.ts:98

Gets the user's device OS

Returns​

"Windows" | "Mac" | "Linux" | "Android" | "iOS" | "Other"

OS Name: Windows, Mac, Linux, Android, iOS, or Other