Skip to content

Commit

Permalink
fix: wrong base url in the api request
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed May 16, 2024
1 parent 09a270b commit 432a404
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ interface GetContentResponse {
}[]
}

const baseUrl = (endpoint: string) => endpoint.replace(/\/api\/graphql$/, '')

const getContent = async (
endpoint: string,
apiKey: string,
libraryItemIds: string[],
): Promise<GetContentResponse> => {
const response = await requestUrl({
url: `${endpoint}/api/content`,
url: `${baseUrl(endpoint)}/api/content`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -80,7 +82,7 @@ const fetchContentForItems = async (
item.content = await Promise.race([
downloadFromUrl(c.downloadUrl),
new Promise<string>(
(_, reject) => setTimeout(() => reject('Timeout'), 600_000), // 10 minutes
(_, reject) => setTimeout(() => reject('Timeout'), 60_000), // 60 seconds
),
])
}),
Expand All @@ -99,7 +101,7 @@ export const getItems = async (
): Promise<[Item[], boolean]> => {
const omnivore = new Omnivore({
authToken: apiKey,
baseUrl: endpoint,
baseUrl: baseUrl(endpoint),
timeoutMs: 10000, // 10 seconds
})

Expand Down Expand Up @@ -130,7 +132,7 @@ export const deleteItem = async (
) => {
const omnivore = new Omnivore({
authToken: apiKey,
baseUrl: endpoint,
baseUrl: baseUrl(endpoint),
timeoutMs: 10000, // 10 seconds
})

Expand Down

0 comments on commit 432a404

Please sign in to comment.