mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
Fix crashing when fetching 404 registry
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import { CollectionRegistry } from '@mcschema/core'
|
||||
|
||||
export const mcdata = (version: string, registry: string) => `https://raw.githubusercontent.com/Arcensoth/mcdata/${version}/processed/reports/registries/${registry}/${registry}.min.json`
|
||||
export const mcdata = (version: string, registry: string) => `https://raw.githubusercontent.com/Arcensoth/mcdata/${version}/processed/reports/registries/${registry}/${registry.split('/').slice(-1)[0]}.min.json`
|
||||
|
||||
export const RegistryFetcher = async (target: CollectionRegistry, registries: string[], version = 'master') => {
|
||||
await Promise.all(registries.map(async r => {
|
||||
const res = await fetch(mcdata(version, r))
|
||||
const data = await res.json()
|
||||
target.register(r, data.values)
|
||||
try {
|
||||
const res = await fetch(mcdata(version, r))
|
||||
const data = await res.json()
|
||||
target.register(r, data.values)
|
||||
} catch (e) {
|
||||
console.error(`Error occurred while fetching registry for ${r}.`, e)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user