Search code examples
javascripttypescripttypeerror

Where from to import Response Error type in Typescript


Im trying to find the source of Response Error Type. What package should I install to handle such error types


import Error from '??';

export const fetchList = createAsyncThunk(
  'list-get',
  async () => {
    try {
      const response = await doFetch(..);
      return response.data
    } catch (error: Error) {
      if(error.response.status === 0 ){
        doHandling();
      } else
      throw error;
    }
  }
)


Solution

  • There is no type to import from. error's type should be unknown, not Error, as we can throw everything.