Reduxtoolkit Query :: access all request

Viewed 14

I have a react-native project that uses RTK Query.

I want to integrate Firebase/perf library.

s there a way to hook into all fetch request at one place. So I can mesure each fetch?

Firebase/perf integration in a function ::

 // Define the network metric
  const metric = await perf().newHttpMetric(url, 'GET');

  // Define meta details
  metric.putAttribute('user', 'abcd');

  // Start the metric
  await metric.start();

  // Perform a HTTP request and provide response information
  const response = await fetch(url);


  metric.setHttpResponseCode(response.status);
  metric.setResponseContentType(response.headers.get('Content-Type'));
  metric.setResponsePayloadSize(response.headers.get('Content-Length'));

  // Stop the metric
  await metric.stop();

I would like to replace the fetch in this snippet with the RTK Query main fetch function.

Anyone ever done this integration ?

Thanks for your help.

0 Answers
Related