/projects now supports IDs **and** slugs

Yay!
This commit is contained in:
Kir_Antipov 2024-01-04 09:21:05 +00:00
parent 940eefb550
commit ef46ac5abb

View file

@ -115,18 +115,14 @@ export class ModrinthApiClient {
} }
/** /**
* Fetches multiple projects by their IDs. * Fetches multiple projects by their IDs and/or slugs.
* *
* @param ids - The project IDs. * @param idsOrSlugs - The project IDs and/or slugs.
* *
* @returns An array of projects. * @returns An array of projects.
*
* @remarks
*
* This method **DOES NOT** support slugs (for some reason).
*/ */
async getProjects(ids: Iterable<string>): Promise<ModrinthProject[]> { async getProjects(idsOrSlugs: Iterable<string>): Promise<ModrinthProject[]> {
const response = await this._fetch("/projects", HttpRequest.get().with({ ids: JSON.stringify(asArray(ids)) })); const response = await this._fetch("/projects", HttpRequest.get().with({ ids: JSON.stringify(asArray(idsOrSlugs)) }));
return (await response.json()) ?? []; return (await response.json()) ?? [];
} }