1- import { StatusCodes } from "http-status-codes"
2- import { HttpInternalServerError , HttpUnauthorizedError , HttpPaymentRequiredError } from "../models/errors"
1+ import { StatusCodes } from 'http-status-codes' ;
2+ import {
3+ HttpInternalServerError ,
4+ HttpUnauthorizedError ,
5+ HttpPaymentRequiredError ,
6+ } from '../models/errors' ;
37
4- export const _fetch = async ( input : RequestInfo , init ?: RequestInit ) : Promise < Response > => {
5- const response = await fetch ( input , init )
6-
7- // Throw exception when the general status code is received.
8- if ( response . status === StatusCodes . INTERNAL_SERVER_ERROR ) {
9- throw new HttpInternalServerError ( "The internal server error occurs." )
10- } else if ( response . status === StatusCodes . UNAUTHORIZED ) {
11- throw new HttpUnauthorizedError ( "The session is expired." )
12- } else if ( response . status === StatusCodes . PAYMENT_REQUIRED ) {
13- throw new HttpPaymentRequiredError ( "The license is expired." )
14- }
8+ export const _fetch = async (
9+ input : RequestInfo ,
10+ init ?: RequestInit
11+ ) : Promise < Response > => {
12+ const response = await fetch ( input , init ) ;
1513
16- return response
17- }
14+ // Throw exception when the general status code is received.
15+ if ( response . status === StatusCodes . INTERNAL_SERVER_ERROR ) {
16+ throw new HttpInternalServerError ( 'The internal server error occurs.' ) ;
17+ } else if ( response . status === StatusCodes . UNAUTHORIZED ) {
18+ throw new HttpUnauthorizedError ( 'The session is expired.' ) ;
19+ } else if ( response . status === StatusCodes . PAYMENT_REQUIRED ) {
20+ throw new HttpPaymentRequiredError ( 'The license is expired.' ) ;
21+ }
22+
23+ return response ;
24+ } ;
0 commit comments