Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 127x 29x 29x 27x | import axios, { isAxiosError } from 'axios' import { ApiGetLastWillResponse } from '../../../types/api' type GetLastWillByIdResponse = ApiGetLastWillResponse | 'NOT_FOUND' | 'ERROR' /** * Get last will by id * @param id Last will id * @returns Last will data or error */ export const getLastWillById = async (id: string): Promise<GetLastWillByIdResponse> => { try { const response = await axios.get<ApiGetLastWillResponse>(`${process.env.NEXT_PUBLIC_API_BASE_URL}/lastwill/${id}`) return response.data } catch (error) { if (isAxiosError(error) && error.response?.status === 404) { return 'NOT_FOUND' } return 'ERROR' } } |