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

Add new types #722

This commit is contained in:
xmflsct
2023-03-14 10:50:22 +01:00
parent f78693eee8
commit a0b3b38d8d
5 changed files with 225 additions and 107 deletions

View File

@ -4,27 +4,12 @@ import { AxiosError } from 'axios'
export type QueryKeyNeodb = ['Neodb', { path: string }]
const queryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyNeodb>) => {
const data: any = {}
await Promise.all([
apiGeneral({
method: 'get',
domain: 'neodb.social',
url: `/${queryKey[1].path}`
}).then(res => {
const matches = (res.body as string).match(/"(\/media\/.+autocrop.+?)"/)
data.image = matches?.[1]
}),
apiGeneral({
method: 'get',
domain: 'neodb.social',
url: `/api/${queryKey[1].path}`
}).then(res => (data.data = res.body))
])
return data
}
const queryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyNeodb>) =>
apiGeneral({
method: 'get',
domain: 'neodb.social',
url: `/api/${queryKey[1].path}`
}).then(res => res.body)
export const useNeodbQuery = (
params: QueryKeyNeodb[1] & {