diff --git a/typescript-client/client.ts b/typescript-client/client.ts index cfe035c7d1..5fc616fbe6 100644 --- a/typescript-client/client.ts +++ b/typescript-client/client.ts @@ -188,12 +188,14 @@ function getParamNames(func: Function): string[] { } export function task(f: (_: P) => T): (_: P) => Promise { + !clientSet && setClient(); + return async (...y) => { const args: Record = {}; const paramNames = getParamNames(f); y.forEach((x, i) => (args[paramNames[i]] = x)); let req = await fetch( - `http://0.0.0.0:8000/api/w/foo/jobs/run/workflow_as_code/${getEnv( + `${OpenAPI.BASE}/w/${getWorkspace()}/jobs/run/workflow_as_code/${getEnv( "WM_JOB_ID" )}/${f.name}`, { @@ -216,6 +218,8 @@ export async function runScriptAsync( args: Record | null, scheduledInSeconds: number | null = null ): Promise { + !clientSet && setClient(); + // Create a script job and return its job id. if (path && hash_) { throw new Error("path and hash_ are mutually exclusive");