Skip to content

Commit

Permalink
fix: try/catch around fetch (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
matmut7 authored Jan 8, 2024
1 parent 1f46809 commit c6d9e1c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/utils/rest-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import logger from "./logger"

const fetcher = async (url: string, params: Record<string, unknown>) => {
const response = await fetch(url, params)
if (!response.ok) {
logger.error({ response }, "Error status in response")
return null
try {
const response = await fetch(url, params)
if (!response.ok) {
logger.error({ response }, "Error status in response")
return null
}
return response
} catch (error) {
logger.error("Error attempting to fetch", error)
}
return response
}

export default fetcher

0 comments on commit c6d9e1c

Please sign in to comment.