1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Try if can find out why badge is not cleared

This commit is contained in:
xmflsct
2022-11-23 21:31:58 +01:00
parent a9d40079cc
commit 6c17123fe3
6 changed files with 80 additions and 96 deletions

View File

@ -12,7 +12,6 @@ export type Params = {
}
headers?: { [key: string]: string }
body?: FormData | Object
sentry?: boolean
}
export const TOOOT_API_DOMAIN = mapEnvironment({
@ -26,16 +25,15 @@ const apiTooot = async <T = unknown>({
url,
params,
headers,
body,
sentry = true
body
}: Params): Promise<{ body: T }> => {
console.log(
ctx.bgGreen.bold(' API tooot ') +
' ' +
method +
ctx.green(' -> ') +
`/${url}` +
(params ? ctx.green(' -> ') : ''),
' ' +
method +
ctx.green(' -> ') +
`/${url}` +
(params ? ctx.green(' -> ') : ''),
params ? params : ''
)
@ -46,10 +44,7 @@ const apiTooot = async <T = unknown>({
url: `${url}`,
params,
headers: {
'Content-Type':
body && body instanceof FormData
? 'multipart/form-data'
: 'application/json',
'Content-Type': body && body instanceof FormData ? 'multipart/form-data' : 'application/json',
Accept: '*/*',
...userAgent,
...headers
@ -62,14 +57,14 @@ const apiTooot = async <T = unknown>({
})
})
.catch(error => {
if (sentry) {
Sentry.setExtras({
API: 'tooot',
...(error?.response && { response: error.response }),
...(error?.request && { request: error.request })
})
Sentry.captureException(error)
}
Sentry.setExtras({
API: 'tooot',
request: { url, params, body },
...(error?.response && { response: error.response })
})
Sentry.captureMessage('API error', {
contexts: { errorObject: error }
})
return handleError(error)
})