BackendSrv: Make it possible to pass options to .get|post|patch... methods (#51316)
* feat: make it possible to pass in `options` to `.get()`, `.post()`, etc methods * feat(Datasource): make it possible to specify `optinos` for `getResource()` and `postResource()` * fix(BackendSrv): use partial `BackendSrvRequest` * feat(Datasource): make it possible to set `options` for resource requests * refactor(BackendSrv): remove internal usage of `.request()` * fix(GettingStarted): remove unnecessary import * fix: fix type issues by typing the delete dashboard response * refactor: use more strict types for `params` By reusing the type of `BackendSrvRequest.params` * refactor: make the options paramater partial * fix: extract `data` from the fetch response * docs: update the deprecation notice or `BackendSrv.request()` * refactor: use `.request()` as if it was private * refactor: remove unnecessary change
This commit is contained in:
@@ -143,15 +143,16 @@ export function isFetchError(e: unknown): e is FetchError {
|
||||
* @public
|
||||
*/
|
||||
export interface BackendSrv {
|
||||
get<T = any>(url: string, params?: any, requestId?: string): Promise<T>;
|
||||
delete<T = any>(url: string, data?: any): Promise<T>;
|
||||
post<T = any>(url: string, data?: any): Promise<T>;
|
||||
patch<T = any>(url: string, data?: any): Promise<T>;
|
||||
put<T = any>(url: string, data?: any): Promise<T>;
|
||||
get<T = any>(url: string, params?: any, requestId?: string, options?: Partial<BackendSrvRequest>): Promise<T>;
|
||||
delete<T = any>(url: string, data?: any, options?: Partial<BackendSrvRequest>): Promise<T>;
|
||||
post<T = any>(url: string, data?: any, options?: Partial<BackendSrvRequest>): Promise<T>;
|
||||
patch<T = any>(url: string, data?: any, options?: Partial<BackendSrvRequest>): Promise<T>;
|
||||
put<T = any>(url: string, data?: any, options?: Partial<BackendSrvRequest>): Promise<T>;
|
||||
|
||||
/**
|
||||
* @deprecated Use the fetch function instead. If you prefer to work with a promise
|
||||
* wrap the Observable returned by fetch with the lastValueFrom function.
|
||||
* @deprecated Use the `.fetch()` function instead. If you prefer to work with a promise
|
||||
* wrap the Observable returned by fetch with the lastValueFrom function, or use the get|delete|post|patch|put methods.
|
||||
* This method is going to be private from Grafana 10.
|
||||
*/
|
||||
request<T = any>(options: BackendSrvRequest): Promise<T>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user