add Rainfalls Index page
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {useState} from "react";
|
||||
import axios from "axios";
|
||||
import React from "react";
|
||||
|
||||
const useAxiosTools = () => {
|
||||
|
||||
@@ -8,8 +9,19 @@ const useAxiosTools = () => {
|
||||
|
||||
const axiosGet = axios.get
|
||||
const axiosPost = axios.post
|
||||
const axiosPut = axios.put
|
||||
const axiosDelete = axios.delete
|
||||
|
||||
return {loading, setLoading, error, setError, axiosGet, axiosPost}
|
||||
const errorCatch = (error: any) => {
|
||||
setError(error.response.data.message || error.message)
|
||||
}
|
||||
|
||||
const errorLabel = () => {
|
||||
|
||||
return error ? <div className="bg-red-600 rounded m-2 text-center text-white px-2 py-1 mx-auto">{error}</div>: null
|
||||
}
|
||||
|
||||
return {loading, setLoading, error, setError, errorCatch, errorLabel, axiosGet, axiosPost, axiosPut, axiosDelete}
|
||||
}
|
||||
|
||||
export default useAxiosTools
|
||||
|
||||
Reference in New Issue
Block a user