From 4782a8dd708ec1f68bf469907024c082d606dc79 Mon Sep 17 00:00:00 2001 From: Ritesh Ghosh Date: Sun, 3 Mar 2024 20:05:42 +0530 Subject: feat: add axios config for future code reusability --- src/config/axios.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/config/axios.ts (limited to 'src') diff --git a/src/config/axios.ts b/src/config/axios.ts new file mode 100644 index 0000000..6292e9f --- /dev/null +++ b/src/config/axios.ts @@ -0,0 +1,21 @@ +import axios, { AxiosError, type AxiosRequestConfig } from "axios"; +import { + SRC_BASE_URL, + ACCEPT_HEADER, + USER_AGENT_HEADER, + ACCEPT_ENCODING_HEADER, +} from "../utils/constants.js"; + +const clientConfig: AxiosRequestConfig = { + timeout: 10000, + baseURL: SRC_BASE_URL, + headers: { + Accept: ACCEPT_HEADER, + "User-Agent": USER_AGENT_HEADER, + "Accept-Encoding": ACCEPT_ENCODING_HEADER, + }, +}; + +const client = axios.create(clientConfig); + +export { client, AxiosError }; -- cgit v1.2.3