export function handleResponses()

in client/components/mma/shared/asyncComponents/DefaultApiResponseHandler.tsx [15:32]


export function handleResponses(
	response: Response | Response[],
	// eslint-disable-next-line @typescript-eslint/no-explicit-any -- we're assuming the transformResponse attribute's output can be of multiple types
	transformResponse: (response: Response) => any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- we don't know the final output of the promise?
): Promise<any> {
	if (hasBadResponse(response)) {
		throw new Error('Invalid API response');
	}

	if (Array.isArray(response)) {
		return Promise.all(
			response.map((r) => handleSingleResponse(r, transformResponse)),
		);
	}

	return handleSingleResponse(response, transformResponse);
}