Promise type fix

This commit is contained in:
Gleb Koval 2021-07-03 10:53:43 +01:00
parent 577cf284b2
commit 98f3b98055
No known key found for this signature in database
GPG Key ID: 120F2F6DA9D995FB
1 changed files with 15 additions and 15 deletions

View File

@ -1,11 +1,9 @@
import { authorize, requestWithDefaults } from "./util";
export type HypixelResponse<T> = Promise<
{
_response: Response;
success: boolean;
} & T
>;
export type HypixelResponse<T> = {
_response: Response;
success: boolean;
} & T;
export const ENDPOINT = "https://api.hypixel.net/";
const request = requestWithDefaults(ENDPOINT);
@ -15,15 +13,17 @@ const request = requestWithDefaults(ENDPOINT);
* @param key API key
* @returns A response with the API key information
*/
export async function getAPIKeyInformation(key: string): HypixelResponse<{
record?: {
key: string;
owner: string;
limit: number;
queriesInPastMin: number;
totalQueries: number;
};
}> {
export async function getAPIKeyInformation(key: string): Promise<
HypixelResponse<{
record?: {
key: string;
owner: string;
limit: number;
queriesInPastMin: number;
totalQueries: number;
};
}>
> {
let response = await request("/key", authorize(key));
return {
...(await response.json()),