Skip to content

Commit 432a404

Browse files
committed
fix: wrong base url in the api request
1 parent 09a270b commit 432a404

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/api.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ interface GetContentResponse {
1616
}[]
1717
}
1818

19+
const baseUrl = (endpoint: string) => endpoint.replace(/\/api\/graphql$/, '')
20+
1921
const getContent = async (
2022
endpoint: string,
2123
apiKey: string,
2224
libraryItemIds: string[],
2325
): Promise<GetContentResponse> => {
2426
const response = await requestUrl({
25-
url: `${endpoint}/api/content`,
27+
url: `${baseUrl(endpoint)}/api/content`,
2628
method: 'POST',
2729
headers: {
2830
'Content-Type': 'application/json',
@@ -80,7 +82,7 @@ const fetchContentForItems = async (
8082
item.content = await Promise.race([
8183
downloadFromUrl(c.downloadUrl),
8284
new Promise<string>(
83-
(_, reject) => setTimeout(() => reject('Timeout'), 600_000), // 10 minutes
85+
(_, reject) => setTimeout(() => reject('Timeout'), 60_000), // 60 seconds
8486
),
8587
])
8688
}),
@@ -99,7 +101,7 @@ export const getItems = async (
99101
): Promise<[Item[], boolean]> => {
100102
const omnivore = new Omnivore({
101103
authToken: apiKey,
102-
baseUrl: endpoint,
104+
baseUrl: baseUrl(endpoint),
103105
timeoutMs: 10000, // 10 seconds
104106
})
105107

@@ -130,7 +132,7 @@ export const deleteItem = async (
130132
) => {
131133
const omnivore = new Omnivore({
132134
authToken: apiKey,
133-
baseUrl: endpoint,
135+
baseUrl: baseUrl(endpoint),
134136
timeoutMs: 10000, // 10 seconds
135137
})
136138

0 commit comments

Comments
 (0)