Skip to content

fix request baseURL #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions factory/createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type CreateClientOptions = {
key?: string;
secret?: string;
accessToken?: string;
baseURL?: string;
baseURL?: (typeof baseURLs)[BaseURLKey];
paper?: boolean;
tokenBucket?: TokenBucketOptions;
};
Expand All @@ -54,7 +54,7 @@ export const createClient = (options: CreateClientOptions) => {
throw new Error("Missing credentials (need accessToken or key/secret)");
}

const baseURL = options.baseURL || (paper ? baseURLs.paper : baseURLs.live);
const defaultBaseURL = options.baseURL || (paper ? baseURLs.paper : baseURLs.live);

// Create a token bucket for rate limiting
const bucket = createTokenBucket(options.tokenBucket);
Expand All @@ -65,6 +65,7 @@ export const createClient = (options: CreateClientOptions) => {
path,
params,
data,
baseURL = defaultBaseURL
}: RequestOptions<T>): Promise<T> => {
await new Promise((resolve) => {
// Poll the token bucket every second
Expand Down