0.0.5 • Published 11 months ago
@gohanfromgoku/api-kit v0.0.5
@gohanfromgoku/api-kit
Install
npm i @gohanfromgoku/api-kityarn add @gohanfromgoku/api-kitUsage
// API.js
import createAPIHandler from "@gohanfromgoku/api-kit";
const api = createAPIHandler({ baseURL: YOUR_API_BASE_URL })
export default api// services.js
import api from "./API.js";
const services = {
fetchFomEndpoint: async () => await api.GET(ENDPOINT)
}
export default services// App.jsx
import scrapeServices from './services.js'
const App = ()=>{
useEffect(() => {
const init = async () => {
const response = await services.fetchFomEndpoint()
console.log("response", response)
}
init()
}, [])
return <Component/>
}- Similarly you have
POST,PUT, andDELETEalso in the api.