#I keep getting unhandled error in my

1 messages · Page 1 of 1 (latest)

merry geode
vital wigeonBOT
#

Hi @merry geode. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

merry geode
#
export const apiFetch: ApiFetchFn = async <T>({
  url,
  method = 'GET',
  body,
  headers,
  ...rest
}: RequestInit & { url: string }): Promise<T> => {
  const requestConfig: RequestInit = {
    method,
    body: body ? JSON.stringify(body) : undefined,
    headers: new Headers({
      'Content-Type': 'application/json',
      ...headers,
      Authorization: `Bearer ${getToken()}`,
    }),
    cache: 'no-store',
    credentials: 'include',

    ...rest,
  }

  const baseURL = process.env.REACT_APP_SERVER_URL

  const response = await fetch(`${baseURL}${url}`, requestConfig)
  const data = await response.json()
  if (response.ok) {
    return data
  } else {
    console.log(data.message, 'error')
    throw new Error(data.message || 'Something went wrong')
  }
}

the docs said that throwing an error will go to the closest error boundary
I am throwing it and I am seeing the error boundary page , however I still get the unhandled error

vital wigeonBOT
#

Sorry @merry geode, I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist:

Perhaps try again in 15mins?