responsetype в конфиг
This commit is contained in:
parent
230451ff78
commit
08a3edb3e3
@ -1,4 +1,4 @@
|
|||||||
import axios, { AxiosResponse, Method } from "axios";
|
import axios, { AxiosResponse, Method, ResponseType } from "axios";
|
||||||
import { getAuthToken, setAuthToken } from "../stores/auth";
|
import { getAuthToken, setAuthToken } from "../stores/auth";
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export async function makeRequest<TRequest = unknown, TResponse = unknown>({
|
|||||||
/** Send access token */
|
/** Send access token */
|
||||||
useToken?: boolean;
|
useToken?: boolean;
|
||||||
contentType?: boolean;
|
contentType?: boolean;
|
||||||
responseType?: string;
|
responseType?: ResponseType;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
/** Send refresh token */
|
/** Send refresh token */
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
@ -26,7 +26,6 @@ export async function makeRequest<TRequest = unknown, TResponse = unknown>({
|
|||||||
const headers: Record<string, string> = {};
|
const headers: Record<string, string> = {};
|
||||||
if (useToken) headers["Authorization"] = `Bearer ${getAuthToken()}`;
|
if (useToken) headers["Authorization"] = `Bearer ${getAuthToken()}`;
|
||||||
if (contentType) headers["Content-Type"] = "application/json";
|
if (contentType) headers["Content-Type"] = "application/json";
|
||||||
headers["Response-Type"] = responseType;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios<TRequest, AxiosResponse<TResponse & { accessToken?: string; }>>({
|
const response = await axios<TRequest, AxiosResponse<TResponse & { accessToken?: string; }>>({
|
||||||
@ -35,6 +34,7 @@ export async function makeRequest<TRequest = unknown, TResponse = unknown>({
|
|||||||
headers,
|
headers,
|
||||||
data: body,
|
data: body,
|
||||||
signal,
|
signal,
|
||||||
|
responseType,
|
||||||
withCredentials,
|
withCredentials,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@frontend/kitui",
|
"name": "@frontend/kitui",
|
||||||
"version": "1.0.79",
|
"version": "1.0.80",
|
||||||
"description": "test",
|
"description": "test",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.js",
|
"module": "./dist/index.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user