Skip to content

Commit

Permalink
Better error handling with logging tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Spicer Matthews committed Sep 26, 2024
1 parent 5b58c50 commit d5eb8d8
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,24 +437,38 @@ const Index = ({ data: fallbackData, userAgent }) => {
const enableBackgroundImages = showBackgroundImages()

const logTabWithV5 = async () => {
const userToken = localStorageMgr.getItem('access_token')
try {
const userToken = localStorageMgr.getItem('access_token')

// This should not happen
if (!userToken) {
return
}
// This should not happen
if (!userToken) {
return
}

const headers = {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${userToken}`,
}
const headers = {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${userToken}`,
}

const response = await fetch(
`${process.env.NEXT_PUBLIC_API_ENDPOINT}/api/v1/tab/log`,
{
method: 'POST',
headers,
body: JSON.stringify({}),
}
)

fetch(`${process.env.NEXT_PUBLIC_API_ENDPOINT}/api/v1/tab/log`, {
method: 'POST',
headers,
body: JSON.stringify({}),
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
} catch (error) {
console.error(

Check failure on line 467 in src/pages/index.js

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
'logTabWithV5: There was a problem with the fetch operation:',
error
)
}
}

useEffect(() => {
Expand Down

0 comments on commit d5eb8d8

Please sign in to comment.