NTP-17996 | RN Changes for iOS (#14059)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { handleError, handleSuccess } from "./ApiClient";
|
||||
import { AxiosRequestConfig } from "axios";
|
||||
import { BASE_URL } from "./NetworkConstant";
|
||||
import axios from "axios";
|
||||
import axios, { AxiosRequestConfig } from "axios";
|
||||
import { Platform } from "react-native";
|
||||
import { OsTypeConstants } from "../App/common/constants";
|
||||
import { getBuildConfigDetails } from "../App/common/utilities/CacheUtils";
|
||||
import { getDefaultHeaderData, handleError, handleSuccess } from "./ApiClient";
|
||||
import { BASE_URL } from "./NetworkConstant";
|
||||
import { addBundleVersionToHeader } from "./NetworkUtils";
|
||||
|
||||
function newAbortSignal(timeoutMs: number): AbortSignal {
|
||||
@@ -28,11 +29,16 @@ export const get = async <T>(
|
||||
headers: requestConfig.headers,
|
||||
signal: newAbortSignal(11000),
|
||||
});
|
||||
|
||||
if (params) {
|
||||
requestConfig.params = params;
|
||||
}
|
||||
|
||||
if (Platform.OS === OsTypeConstants.IOS) {
|
||||
const nativeHeaders = await getDefaultHeaderData();
|
||||
requestConfig.headers = {
|
||||
...requestConfig,
|
||||
...nativeHeaders,
|
||||
};
|
||||
}
|
||||
addBundleVersionToHeader(axiosInstance);
|
||||
|
||||
const response = await axiosInstance.get<T>(baseUrl + url, requestConfig);
|
||||
@@ -59,7 +65,13 @@ export const post = async <T>(
|
||||
headers: requestConfig.headers,
|
||||
signal: newAbortSignal(11000),
|
||||
});
|
||||
|
||||
if (Platform.OS === OsTypeConstants.IOS) {
|
||||
const nativeHeaders = await getDefaultHeaderData();
|
||||
requestConfig.headers = {
|
||||
...requestConfig,
|
||||
...nativeHeaders,
|
||||
};
|
||||
}
|
||||
addBundleVersionToHeader(axiosInstance);
|
||||
|
||||
const response = await axiosInstance.post<T>(
|
||||
@@ -90,7 +102,13 @@ export const patch = async <T>(
|
||||
headers: requestConfig.headers,
|
||||
signal: newAbortSignal(11000),
|
||||
});
|
||||
|
||||
if (Platform.OS === OsTypeConstants.IOS) {
|
||||
const nativeHeaders = await getDefaultHeaderData();
|
||||
requestConfig.headers = {
|
||||
...requestConfig,
|
||||
...nativeHeaders,
|
||||
};
|
||||
}
|
||||
addBundleVersionToHeader(axiosInstance);
|
||||
|
||||
const response = await axiosInstance.patch<T>(
|
||||
|
||||
Reference in New Issue
Block a user