makerequest принимает response type
This commit is contained in:
parent
be6f3cdce6
commit
230451ff78
@ -8,6 +8,7 @@ export async function makeRequest<TRequest = unknown, TResponse = unknown>({
|
|||||||
body,
|
body,
|
||||||
useToken = true,
|
useToken = true,
|
||||||
contentType = false,
|
contentType = false,
|
||||||
|
responseType = "json",
|
||||||
signal,
|
signal,
|
||||||
withCredentials,
|
withCredentials,
|
||||||
}: {
|
}: {
|
||||||
@ -17,6 +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;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
/** Send refresh token */
|
/** Send refresh token */
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
@ -24,6 +26,7 @@ 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; }>>({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@frontend/kitui",
|
"name": "@frontend/kitui",
|
||||||
"version": "1.0.78",
|
"version": "1.0.79",
|
||||||
"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