2019-10-18 16:20:01 +00:00
|
|
|
import { Platform } from 'react-native';
|
|
|
|
import DeviceInfo from 'react-native-device-info';
|
|
|
|
|
2020-01-28 13:24:29 +00:00
|
|
|
// this form is required by Rocket.Chat's parser in "app/statistics/server/lib/UAParserCustom.js"
|
|
|
|
export const headers = { 'User-Agent': `RC Mobile; ${ Platform.OS } ${ DeviceInfo.getSystemVersion() }; v${ DeviceInfo.getVersion() } (${ DeviceInfo.getBuildNumber() })` };
|
2019-10-18 16:20:01 +00:00
|
|
|
|
|
|
|
export default (url, options = {}) => {
|
|
|
|
let customOptions = { ...options, headers };
|
|
|
|
if (options && options.headers) {
|
|
|
|
customOptions = { ...customOptions, headers: { ...options.headers, ...headers } };
|
|
|
|
}
|
|
|
|
return fetch(url, customOptions);
|
|
|
|
};
|