Skip to content

Commit

Permalink
fix: debug sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony23991 committed Sep 19, 2024
1 parent e1729d8 commit 38ba1e4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/@justaname.id/sdk/src/lib/api/axiosController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export let BASE_URL = 'https://api.justaname.id';
function loadEnv() {
let isDevelopment = false;

console.log('checking env');
if (typeof process !== 'undefined' && process.env) {
console.log('env', process.env);
try {
isDevelopment = process.env['JUSTANAME_ENVIRONMENT'] === 'development' ||
isDevelopment =
process.env['JUSTANAME_ENVIRONMENT'] === 'development' ||
process.env['NEXT_PUBLIC_JUSTANAME_ENVIRONMENT'] === 'development' ||
process.env['VITE_JUSTANAME_ENVIRONMENT'] === 'development' ||
process.env['NODE_ENV'] === 'test';
Expand All @@ -20,7 +23,9 @@ function loadEnv() {
}
}

BASE_URL = isDevelopment ? 'https://api-staging.justaname.id' : 'https://api.justaname.id';
BASE_URL = isDevelopment
? 'https://api-staging.justaname.id'
: 'https://api.justaname.id';
}

loadEnv();
Expand All @@ -35,14 +40,13 @@ export const justANameInstance = axios.create({
baseURL: getBaseUrl(),
});


/**
* Represents the Controlled Axios Promise type.
* @typeparam T - The type of the data to be returned.
*/
export type ControlledAxiosPromise<T extends {}> =
AxiosPromise<BaseResponse<T>>;

export type ControlledAxiosPromise<T extends {}> = AxiosPromise<
BaseResponse<T>
>;

/**
* Represents the controlled axios promise.
Expand All @@ -67,4 +71,4 @@ export const controlledAxiosPromise = <T extends NonNullable<unknown>>(
}
}
throw err;
});
});

0 comments on commit 38ba1e4

Please sign in to comment.