Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion prometheus/src/model/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export type { DurationString };
export interface SuccessResponse<T> {
status: 'success';
data: T;
rawResponse?: Response;
warnings?: string[];
infos?: string[];
}

export interface ErrorResponse<T> {
Expand Down
15 changes: 3 additions & 12 deletions prometheus/src/model/prometheus-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ function fetchWithGet<T extends RequestParams<T>, TResponse>(
params: T,
queryOptions: QueryOptions
): Promise<TResponse> {
const { datasourceUrl, headers, queryParams } = queryOptions;
const { datasourceUrl, headers, queryParams, abortSignal: signal } = queryOptions;
const url = `${datasourceUrl}${apiURI}${buildQueryString(queryParams, createSearchParams(params))}`;
return fetchJson<TResponse>(url, { method: 'GET', headers });
return fetchJson<TResponse>(url, { method: 'GET', headers, signal });
}

function fetchWithPost<T extends RequestParams<T>, TResponse>(
Expand All @@ -220,7 +220,7 @@ function fetchWithPost<T extends RequestParams<T>, TResponse>(
signal,
body: createSearchParams(params),
};
return fetchResults<TResponse>(url, init);
return fetchJson<TResponse>(url, init);
}

// Request parameter values we know how to serialize
Expand Down Expand Up @@ -257,12 +257,3 @@ function createSearchParams<T extends RequestParams<T>>(params: T): URLSearchPar
}
return searchParams;
}

/**
* Fetch JSON and parse warnings for query inspector
*/
export async function fetchResults<T>(...args: Parameters<typeof global.fetch>): Promise<T> {
const response = await fetch(...args);
const json: T = await response.json();
return { ...json, rawResponse: response };
}
Loading