Last active
April 11, 2021 19:07
-
-
Save ChaseH88/cb6897a205e5667b8fe3bb8b4febd6af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from 'axios'; | |
| /** | |
| * This hook makes use of the axios dependency. | |
| * @param path the endpoint in which you wish to make a request to | |
| * @param method the request method.. can be either 'get' or 'post'. | |
| * @param data an object containing the data/payload | |
| * @returns | |
| */ | |
| const useAxios = async ( | |
| path: string, | |
| method: 'get' | 'post' = 'get', | |
| data: { [key: string]: any } = {} | |
| ) => ( | |
| await axios[method](path, data) | |
| ); | |
| export { useAxios }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment