Skip to main content
Version: 3.xx.xx

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-core";

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​

DescriptionType
API URLstring