Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions packages/service/src/service/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ export class BtcAssetsApiBase implements BaseApis {
await this.init();
}

const packedParams = params ? '?' + new URLSearchParams(pickBy(params, (val) => val !== undefined)).toString() : '';
const withOriginHeaders = this.origin ? { origin: this.origin } : undefined;
const withAuthHeaders = requireToken && this.token ? { Authorization: `Bearer ${this.token}` } : undefined;
const pickedParams = pickBy(params, (val) => val !== undefined);
const packedParams = params ? '?' + new URLSearchParams(pickedParams).toString() : '';
const url = `${this.url}${route}${packedParams}`;
const res = await fetch(url, {
method,
headers: {
...withOriginHeaders,
...withAuthHeaders,
authorization: this.token ? `Bearer ${this.token}` : undefined,
origin: this.origin,
...headers,
},
...otherOptions,
Expand Down Expand Up @@ -96,7 +95,7 @@ export class BtcAssetsApiBase implements BaseApis {
if (status !== 200 && status !== 404 && !allow404) {
throw BtcAssetsApiError.withComment(ErrorCodes.ASSETS_API_RESPONSE_ERROR, comment, context);
}
if (status !== 200) {
if (status === 404 && allow404) {
return undefined as T;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/service/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
watch: false,
testTimeout: 15000,
testTimeout: 20000,
reporters: ['verbose'],
exclude: ['lib', 'node_modules'],
},
Expand Down