mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fetch: parse JSON off-main-thread (async) based on response Content-Type (#45188)
This commit is contained in:
parent
cb461d931f
commit
9af6202a7f
@ -20,7 +20,12 @@ import { getConfig } from 'app/core/config';
|
||||
import { DashboardSearchHit } from 'app/features/search/types';
|
||||
import { FolderDTO } from 'app/types';
|
||||
import { ContextSrv, contextSrv } from './context_srv';
|
||||
import { parseInitFromOptions, parseResponseBody, parseUrlFromOptions } from '../utils/fetch';
|
||||
import {
|
||||
isContentTypeApplicationJson,
|
||||
parseInitFromOptions,
|
||||
parseResponseBody,
|
||||
parseUrlFromOptions,
|
||||
} from '../utils/fetch';
|
||||
import { isDataQuery, isLocalUrl } from '../utils/query';
|
||||
import { FetchQueue } from './FetchQueue';
|
||||
import { ResponseQueue } from './ResponseQueue';
|
||||
@ -187,7 +192,9 @@ export class BackendSrv implements BackendService {
|
||||
mergeMap(async (response) => {
|
||||
const { status, statusText, ok, headers, url, type, redirected } = response;
|
||||
|
||||
const data = await parseResponseBody<T>(response, options.responseType);
|
||||
const responseType = options.responseType ?? (isContentTypeApplicationJson(headers) ? 'json' : undefined);
|
||||
|
||||
const data = await parseResponseBody<T>(response, responseType);
|
||||
const fetchResponse: FetchResponse<T> = {
|
||||
status,
|
||||
statusText,
|
||||
|
Loading…
Reference in New Issue
Block a user