0.0.5 • Published 11 months ago

@gohanfromgoku/api-kit v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@gohanfromgoku/api-kit

Install

npm i @gohanfromgoku/api-kit
yarn add @gohanfromgoku/api-kit

Usage

// 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, and DELETE also in the api.
0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

1 year ago

0.0.2

1 year ago