useApiUrl
useApiUrl
lets you access the API URL of the dataProvider
that was configured in <Refine>
component.
This hook uses the getApiUrl
method of the used dataProvider
.
Usage
An example use case might be using it with useCustom
hook.
import {
useCustom,
useApiUrl
} from "@pankod/refine";
interface PostUniqueCheckResponse {
isAvailable: boolean;
}
const apiUrl = useApiUrl();
const { data, isLoading } = useCustom<PostUniqueCheckResponse>({
url: `${apiUrl}/posts-unique-check`,
method: "get",
config: {
query: {
title: "Foo bar",
},
},
});
API
Return value
Description | Type |
---|---|
API URL | string |