diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..5788575 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/classes/providers/HandleClientProvider.abstract.class.ts b/src/classes/providers/HandleClientProvider.abstract.class.ts index f2caedd..435060e 100644 --- a/src/classes/providers/HandleClientProvider.abstract.class.ts +++ b/src/classes/providers/HandleClientProvider.abstract.class.ts @@ -50,18 +50,22 @@ export abstract class HandleClientProvider { * @param {HEX} handle - The handle supplied to the lookup. * @returns */ - protected async __handleResponse(api: Promise, handle: Readable) { + protected async __handleResponse(api: Promise, handle?: Readable) { return api .then((res) => res.json() as T) .catch((e) => { - console.error( - `Something went wrong while fetching this Handle: ${handle.value}.${ - isHex(handle.value) - ? ` You may need to convert the Handle name to UTF-8 before providing it to this function.` - : '' - } Here is the full error:`, - e - ); + if (handle) { + console.error( + `Something went wrong while fetching this Handle: ${handle.value}.${ + isHex(handle.value) + ? ` You may need to convert the Handle name to UTF-8 before providing it to this function.` + : '' + } Here is the full error:`, + e + ); + } else { + console.error(e); + } return {} as T; }); diff --git a/src/classes/providers/KoraLabsProvider.class.ts b/src/classes/providers/KoraLabsProvider.class.ts index a241d32..fd27575 100644 --- a/src/classes/providers/KoraLabsProvider.class.ts +++ b/src/classes/providers/KoraLabsProvider.class.ts @@ -102,6 +102,23 @@ export class KoraLabsProvider extends HandleClientProvider { ); }; + /** + * Retrieves all data associated with a list of given handles. + * + * @param {HEX[]} handles - The handles to lookup, in HEX format. + * @returns {Promise} - A promise that resolves to an array of handle data. + */ + getAllDataBatch = async (handles: HEX[]): Promise => { + const names = handles.map((h) => HandleClient.getNormalizedName(h).value); + return this.__handleResponse( + fetch(`${this.apiUrl}/handles/list`, { + headers: this.headers, + method: 'POST', + body: JSON.stringify(names) + }) + ); + }; + /** * Retrieves all personalized data associated with a given handle. *