makerequest принимает response type

This commit is contained in:
Nastya 2024-04-15 21:45:44 +03:00
parent be6f3cdce6
commit 230451ff78
2 changed files with 4 additions and 1 deletions

@ -8,6 +8,7 @@ export async function makeRequest<TRequest = unknown, TResponse = unknown>({
body,
useToken = true,
contentType = false,
responseType = "json",
signal,
withCredentials,
}: {
@ -17,6 +18,7 @@ export async function makeRequest<TRequest = unknown, TResponse = unknown>({
/** Send access token */
useToken?: boolean;
contentType?: boolean;
responseType?: string;
signal?: AbortSignal;
/** Send refresh token */
withCredentials?: boolean;
@ -24,6 +26,7 @@ export async function makeRequest<TRequest = unknown, TResponse = unknown>({
const headers: Record<string, string> = {};
if (useToken) headers["Authorization"] = `Bearer ${getAuthToken()}`;
if (contentType) headers["Content-Type"] = "application/json";
headers["Response-Type"] = responseType;
try {
const response = await axios<TRequest, AxiosResponse<TResponse & { accessToken?: string; }>>({

@ -1,6 +1,6 @@
{
"name": "@frontend/kitui",
"version": "1.0.78",
"version": "1.0.79",
"description": "test",
"main": "./dist/index.js",
"module": "./dist/index.js",