Hello,
I’m developing a react datasource plugin that makes calls to an external API via the Grafana proxy. The routing is set up in plugin.json and is working as expected when I use backendSrv.datasourceRequest() from DataSource.ts:
response = await this.backendSrv.datasourceRequest({
url: url,
method: method,
data: body,
});
However, these requests are expensive and can take a long time. I would like the request to be cancelled if the user refreshes the page, or resubmits the query. Is there a way to signal this cancellation from the backendSrv? I see that it has a method called handleStreamCancellation and a field called HTTP_REQUEST_CANCELLED, but I’m not sure how to use these.
In case it’s useful, my API is ASP.NET Core and is using a CancellationToken to detect if the request was cancelled.
Thanks!