403Webshell
Server IP : 91.134.83.25  /  Your IP : 216.73.216.79
Web Server : Apache
System : Linux plesk.serveurapc.fr 6.1.0-51-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.177-1 (2026-07-16) x86_64
User : marrasse ( 10057)
PHP Version : 8.2.32
Disable Function : opcache_get_status
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/vhosts/as-cp.fr/wpascp/wp-content/plugins/code-snippets/js/hooks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/as-cp.fr/wpascp/wp-content/plugins/code-snippets/js/hooks/useAxios.ts
import { useMemo } from 'react'
import axios from 'axios'
import type { AxiosInstance, AxiosResponse, CreateAxiosDefaults } from 'axios'

export interface AxiosAPI {
	get: <T>(url: string) => Promise<AxiosResponse<T, never>>
	post: <T, D>(url: string, data?: D) => Promise<AxiosResponse<T, D>>
	del: <T>(url: string) => Promise<AxiosResponse<T, never>>
	axiosInstance: AxiosInstance
}

const debugRequest = async <T, D = never>(
	method: 'GET' | 'POST' | 'PUT' | 'DELETE',
	url: string,
	doRequest: Promise<AxiosResponse<T, D>>,
	data?: D
): Promise<AxiosResponse<T, D>> => {
	console.debug(`${method} ${url}`, ...data ? [data] : [])
	const response = await doRequest
	console.debug('Response', response)
	return response
}

export const useAxios = (defaultConfig: CreateAxiosDefaults): AxiosAPI => {
	const axiosInstance = useMemo(() => axios.create(defaultConfig), [defaultConfig])

	return useMemo((): AxiosAPI => ({
		get: <T>(url: string): Promise<AxiosResponse<T, never>> =>
			debugRequest('GET', url, axiosInstance.get<T, AxiosResponse<T, never>, never>(url)),

		post: <T, D>(url: string, data?: D) =>
			debugRequest('POST', url, axiosInstance.post<T, AxiosResponse<T, D>, D>(url, data), data),

		del: <T>(url: string) =>
			debugRequest('DELETE', url, axiosInstance.delete<T, AxiosResponse<T, never>, never>(url)),

		axiosInstance
	}), [axiosInstance])
}

Youez - 2016 - github.com/yon3zu
LinuXploit