# hostinger/3.0.61/vue-frontend/src/utils/services/httpService.ts

Hostinger Tools, version 3.0.61. 71 lines.

- Page: https://pluginprobe.com/plugins/hostinger/3.0.61/code/vue-frontend/src/utils/services/httpService.ts
- Raw: https://pluginprobe.com/plugins/hostinger/3.0.61/raw/vue-frontend/src/utils/services/httpService.ts
- Modified: 2025-09-09T07:18:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/hostinger/3.0.61/code/vue-frontend/src/utils/services/httpService.ts#L10-L20`.

```typescript
import axios, {
	AxiosRequestConfig,
	AxiosResponse,
	InternalAxiosRequestConfig
} from "axios";

import { asyncCall } from "@/utils/helpers";
import { camelToSnakeObj, snakeToCamelObj } from "@/utils/services";

const TIMEOUT_TIME = 120_000;

export const axiosInstance = axios.create({
	timeout: TIMEOUT_TIME,
	withCredentials: false,
	headers: {
		Accept: "application/json;charset=UTF-8",
		"Content-Type": "application/json;charset=UTF-8"
	}
});

// REQUEST INTERCEPTOR - camel to snake
axiosInstance.interceptors.request.use((req: InternalAxiosRequestConfig) => {
	if ((req as InternalAxiosRequestConfig & { plain?: boolean }).plain)
		return req;

	if (req.data) {
		req.data = camelToSnakeObj(req.data);
	}

	if (req.params) {
		req.params = camelToSnakeObj(req.params);
	}

	return req;
});

axiosInstance.interceptors.response.use(
	(res: AxiosResponse) => {
		const transformedResponse = snakeToCamelObj({
			...res,
			data: res.data
		});

		return transformedResponse as AxiosResponse;
	},
	(error: Error) => Promise.reject(error)
);

const httpService = {
	get<T>(url: string, config?: AxiosRequestConfig) {
		return asyncCall<T>(axiosInstance.get(url, config));
	},
	post<T>(url: string, data?: unknown, config?: AxiosRequestConfig) {
		return asyncCall<T>(axiosInstance.post(url, data, config));
	},
	put<T>(url: string, data?: unknown, config?: AxiosRequestConfig) {
		return asyncCall<T>(axiosInstance.put(url, data, config));
	},
	patch<T>(url: string, data?: unknown, config?: AxiosRequestConfig) {
		return asyncCall<T>(axiosInstance.patch(url, data, config));
	},
	delete<T>(url: string, config?: AxiosRequestConfig) {
		return asyncCall<T>(axiosInstance.delete(url, config));
	},
	request<T>(config: AxiosRequestConfig) {
		return asyncCall<T>(axiosInstance(config));
	}
};

export default httpService;

```
