Moved API types and type helpers to api module

This commit is contained in:
Alejandro Celaya
2020-12-22 09:49:13 +01:00
parent 811544d7df
commit 8c6eaf2f1d
34 changed files with 46 additions and 46 deletions

View File

@@ -1,4 +1,10 @@
import { AxiosError } from 'axios';
import { ProblemDetailsError } from '../../utils/services/types';
import { InvalidArgumentError, InvalidShortUrlDeletion, ProblemDetailsError } from '../types';
export const parseApiError = (e: AxiosError<ProblemDetailsError>) => e.response?.data;
export const isInvalidArgumentError = (error?: ProblemDetailsError): error is InvalidArgumentError =>
error?.type === 'INVALID_ARGUMENT';
export const isInvalidDeletionError = (error?: ProblemDetailsError): error is InvalidShortUrlDeletion =>
error?.type === 'INVALID_SHORTCODE_DELETION';