Skip to content

Commit

Permalink
fix: throw when jwt is null
Browse files Browse the repository at this point in the history
  • Loading branch information
tchardin committed Oct 11, 2023
1 parent 74ce6cf commit 64beb77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/utils/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export async function getJWT (opts, storage) {
const url = `${authURL}?clientKey=${clientKey}`

const result = await fetch(url)
const { token } = await result.json()
const { token, message } = await result.json()

if (!token) throw new Error(message || 'Failed to refresh jwt')

try {
await storage.set(JWT_KEY, token)
Expand Down
2 changes: 1 addition & 1 deletion test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Saturn from '#src/index.js'

const TEST_CID = 'QmXjYBY478Cno4jzdCcPy4NcJYFrwHZ51xaCP8vUwN9MGm'

const clientKey = '1234567890abcdef'
const clientKey = 'abc123'

describe('Saturn client', () => {
describe('constructor', () => {
Expand Down

0 comments on commit 64beb77

Please sign in to comment.