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:
@ -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] & {
|
||||
|
Reference in New Issue
Block a user