UNPKG

@archon-inc/sdk

Version:

Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk

19 lines (17 loc) 643 B
import { Archon } from "../Archon.js"; import { Session, SessionId } from "../types/user.js"; /** * Get the session object from the session ID. * @param sessionId The ID of the session to get. * @returns The session object. */ export default async function getSession(sessionId: SessionId | string): Promise<Session> { if (typeof sessionId !== "number") { sessionId = parseInt(sessionId) as SessionId; } const response = await Archon.request(`/users/session/${sessionId}`, "GET") if (response.status !== 200) { throw new Error(`Failed to retrieve session ${sessionId}.`); } return response.data; }