Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
Unauthorize when access denied (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
lujjjh authored Oct 21, 2021
1 parent 54cfaa1 commit ca7a678
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/lito/src/api/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
export const fetcher = async (url: string) => {
const instance = MusicKit.getInstance()
const {
api,
_bag: { store },
} = MusicKit.getInstance() as any
const { data } = await api.music(url)
return store.populateDataRecords(data)
} = instance as any
try {
const { data } = await api.music(url)
return store.populateDataRecords(data)
} catch (error) {
if (error instanceof MusicKit.MKError && error.errorCode === MusicKit.MKError.ACCESS_DENIED) {
instance.unauthorize()
}
throw error
}
}

0 comments on commit ca7a678

Please sign in to comment.