INNER CODE UNIT · TypeScript
getErrorResponse
gadingnst/fullstack-next-template · src/packages/libs/BaseHttp/index.ts:117
public static async getErrorResponse(err: unknown) {
const error = err as BaseHttpError;
if (!error.response) {
return {
status: 0,
statusText: DEFAULT_ERROR_STATUS,
message: error.message
};
}
const { response } = error;
let message = DEFAULT_HTTP_ERROR_MESSAGE;
try {
const res = await response.json();
message =
typeof res === 'string' && res
? res