This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
react-rest-request/src/client-hook.ts

15 lines
319 B
TypeScript
Raw Normal View History

import Axios from 'axios';
import React from 'react';
import { useRequestContext } from './request-context';
export function useClient() {
const { baseUrl } = useRequestContext();
const client = React.useMemo(
() => Axios.create({ baseURL: baseUrl }),
[baseUrl]
);
return [client];
}