Skip to content

Commit

Permalink
don't throw an error if multiple works returned until datacite/dataci…
Browse files Browse the repository at this point in the history
…te#1836 gets resolved (#426)
  • Loading branch information
bklaing2 authored Dec 2, 2024
1 parent e73f659 commit 021c17e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/data/queries/doiQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function convertToQueryData(work: any, included: any[]): QueryData {
const repo =
work.relationships.client.data && included
? included.find(
(r: Repository) => r.id === work.relationships.client.data.id
) || null
(r: Repository) => r.id === work.relationships.client.data.id
) || null
: null

return {
Expand Down Expand Up @@ -66,8 +66,9 @@ export async function fetchDoi(id: string) {
)
const json = await res.json()

if (json.meta.total === 0) throw new Error('No work found')
if (json.meta.total > 1) throw new Error('Multiple works found')
if (json.meta.total === 0) throw new Error('No works found')
// Don't throw this error until https://github.com/datacite/datacite/issues/1836 gets resolved
// if (json.meta.total > 1) throw new Error('Multiple works found')

const data = convertToQueryData(json.data[0], json.included)
return { data }
Expand Down

0 comments on commit 021c17e

Please sign in to comment.