mirror of
https://github.com/tooot-app/app
synced 2025-01-27 08:51:26 +01:00
Add details to UA
This commit is contained in:
parent
0d9992107c
commit
7ef88c735b
@ -1,6 +1,6 @@
|
||||
import axios from 'axios'
|
||||
import Constants from 'expo-constants'
|
||||
import handleError, { ctx } from './handleError'
|
||||
import { userAgent } from './helpers'
|
||||
|
||||
export type Params = {
|
||||
method: 'get' | 'post' | 'put' | 'delete'
|
||||
@ -44,8 +44,8 @@ const apiGeneral = async <T = unknown>({
|
||||
body && body instanceof FormData
|
||||
? 'multipart/form-data'
|
||||
: 'application/json',
|
||||
'User-Agent': `tooot/${Constants.expoConfig?.version}`,
|
||||
Accept: '*/*',
|
||||
...userAgent,
|
||||
...headers
|
||||
},
|
||||
...(body && { data: body })
|
||||
|
6
src/api/helpers/index.ts
Normal file
6
src/api/helpers/index.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import Constants from "expo-constants"
|
||||
import { Platform } from "react-native"
|
||||
|
||||
const userAgent = { 'User-Agent': `tooot/${Constants.expoConfig?.version} ${Platform.OS}/${Platform.Version}` }
|
||||
|
||||
export { userAgent }
|
@ -1,8 +1,8 @@
|
||||
import { RootState } from '@root/store'
|
||||
import axios, { AxiosRequestConfig } from 'axios'
|
||||
import Constants from 'expo-constants'
|
||||
import li from 'li'
|
||||
import handleError, { ctx } from './handleError'
|
||||
import { userAgent } from './helpers'
|
||||
|
||||
export type Params = {
|
||||
method: 'get' | 'post' | 'put' | 'delete' | 'patch'
|
||||
@ -53,13 +53,13 @@ const apiInstance = async <T = unknown>({
|
||||
|
||||
console.log(
|
||||
ctx.bgGreen.bold(' API instance ') +
|
||||
' ' +
|
||||
domain +
|
||||
' ' +
|
||||
method +
|
||||
ctx.green(' -> ') +
|
||||
`/${url}` +
|
||||
(params ? ctx.green(' -> ') : ''),
|
||||
' ' +
|
||||
domain +
|
||||
' ' +
|
||||
method +
|
||||
ctx.green(' -> ') +
|
||||
`/${url}` +
|
||||
(params ? ctx.green(' -> ') : ''),
|
||||
params ? params : ''
|
||||
)
|
||||
|
||||
@ -74,8 +74,8 @@ const apiInstance = async <T = unknown>({
|
||||
body && body instanceof FormData
|
||||
? 'multipart/form-data'
|
||||
: 'application/json',
|
||||
'User-Agent': `tooot/${Constants.expoConfig?.version}`,
|
||||
Accept: '*/*',
|
||||
...userAgent,
|
||||
...headers,
|
||||
...(token && {
|
||||
Authorization: `Bearer ${token}`
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as Sentry from '@sentry/react-native'
|
||||
import { mapEnvironment } from '@utils/checkEnvironment'
|
||||
import axios from 'axios'
|
||||
import Constants from 'expo-constants'
|
||||
import handleError, { ctx } from './handleError'
|
||||
import { userAgent } from './helpers'
|
||||
|
||||
export type Params = {
|
||||
method: 'get' | 'post' | 'put' | 'delete'
|
||||
@ -50,13 +50,11 @@ const apiTooot = async <T = unknown>({
|
||||
body && body instanceof FormData
|
||||
? 'multipart/form-data'
|
||||
: 'application/json',
|
||||
'User-Agent': `tooot/${Constants.expoConfig?.version}`,
|
||||
Accept: '*/*',
|
||||
...userAgent,
|
||||
...headers
|
||||
},
|
||||
...(body && { data: body }),
|
||||
validateStatus: status =>
|
||||
url.includes('translate') ? status < 500 : status === 200
|
||||
...(body && { data: body })
|
||||
})
|
||||
.then(response => {
|
||||
return Promise.resolve({
|
||||
|
Loading…
x
Reference in New Issue
Block a user