endless-jadeE
Refine3y ago
5 replies
endless-jade

The useApiUrl hook retrieves the default API URL in multiple data providers

According to the documentation, one can use multiple data providers like:

dataProvider={{
  default: dataProvider("https://api.fake-rest.refine.dev"),
  users: dataProvider("https://api.finefoods.refine.dev"),
}}

And in the resource props, I have something like:
resources={[
  {
    name: "users",
    list: "/dashboard",
    meta: {
      label: "Dashboard",
      dataProviderName: "users",
    },
  },
]}

When I try to retrieve the API URL with the useApiUrl hook in the rendered component, I get the default API URL instead of the URL for the specified data provider.
import React from "react";
import { useApiUrl } from "@refinedev/core";

export const DashboardPage: React.FC = () => {
  const API_URL = useApiUrl();
  // This picks the default API_URL
  return (
    <p>
      Data provider: <code>{API_URL}</code>
    </p>
  );
};


Any reason for this? The example project doesn't help that much in this case.
Was this page helpful?