refactor: remove useBaseFetch for @modrinth/api-client (#5596)

* Reapply "fix: start swapping useBaseFetch usages to api-client"

This reverts commit f4f33db7019ea861addb2c66c204d736800b7b6c.

* fix: bugs

* fix: analytics

* fix: lint
This commit is contained in:
Calum H.
2026-03-17 20:06:19 +00:00
committed by GitHub
parent 58c1e225c8
commit 87c86c7d0d
64 changed files with 2073 additions and 691 deletions

View File

@@ -21,6 +21,16 @@ export function fetchSegmented<T>(
).then((results) => results.flat())
}
export function fetchSegmentedWith<TId, TResult>(
data: TId[],
fetchFn: (ids: TId[]) => Promise<TResult[]>,
segmentSize = 800,
): Promise<TResult[]> {
return Promise.all(segmentData(data, segmentSize).map((ids) => fetchFn(ids))).then((results) =>
results.flat(),
)
}
export function asEncodedJsonArray<T>(data: T[]): string {
return encodeURIComponent(JSON.stringify(data))
}