Time Adapter
Use this adapter to get the current server time.
Importing the adapter
To use the Time adapter, import it as shown:
import { timeAdapter } from 'epicenter-libs';
Get server time
The get() function retrieves the current server time.
Permissions
Requires a role of ANONYMOUS or higher.
Function description
- Constructs a
GETrequest to the/timeendpoint. - Returns the current server time in ISO 8601 format.
- If the server responds with
404, the function returnsundefined.
Function signature
export async function get(
optionals: RoutingOptions = {},
): Promise<void | string>
Parameters
optionals(Type:RoutingOptions):accountShortName?(string) – The account short name. By default, the account associated with the current session is used.projectShortName?(string) – The project short name. By default, the project associated with the current session is used.RoutingOptions– Additional routing options.
Return value
A promise that resolves to:
- A
stringrepresenting the current server time in ISO 8601 format, or undefinedif the server does not return a value.
Usage example
import { timeAdapter } from 'epicenter-libs';
const serverTime = await timeAdapter.get();