Files
CordysCRM/frontend/packages/lib-shared/api/http/helper.ts
2024-12-25 18:11:07 +08:00

13 lines
348 B
TypeScript

export function joinTimestamp<T extends boolean>(join: boolean, restful: T): T extends true ? string : object;
export function joinTimestamp(join: boolean, restful = false): string | object {
if (!join) {
return restful ? '' : {};
}
const now = new Date().getTime();
if (restful) {
return `?_t=${now}`;
}
return { _t: now };
}