October 2019
Intermediate to advanced
426 pages
11h 49m
English
We can also create Hooks for the various API calls. Putting these Hooks in a single file allows us to adjust the API calls easily later on. We are going to prefix our custom API Hooks with useAPI so it is easy to tell which functions are API Hooks.
Let's create custom Hooks for our API now using the following steps:
import { useResource } from 'react-request-hook'
export function useAPILogin () { return useResource((username, password) => ({ url: `/login/${encodeURI(username)}/${encodeURI(password)}`, ...Read now
Unlock full access