0.1.2 • Published 11 months ago

simple-query-service v0.1.2

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

Welcome to Simple Query Service!

This is a simple React Hook to handle the state of Promise Call

How to install

  • run npm i simple-query-service
  • install dependencies if is necessary

How it works

import {FetchNow, FetchAsync} from  "simple-query-service"

// example async funtion with axios
const login = async (params):Promise<ResponseTpe> => {
    const  data = await  axios.post(ROUTE, {...params})
    return  data.data
 }
 
// FetchAsync will be executed when you call executeAsync function
const {executeAsync, isLoading, error} = FetchAsync({ query: () =>  login(params)})
const data = await executeAsync()
console.log(data)

// FetchNow is automatically execute and returning data
const {data, isLoading, error} = FetchNow({ query: () =>  login(params)})
console.log(data)

additional you can create your query file and export your hooks (api/login.query.ts)

export const useLogin = () =>  FetchAsync({query: (params: ParamTypes) =>  login(params)})

Calling hook

import { useLogin } from  "./api/login.query";
const {executeAsync, isLoading, error} = useLogin()
const data = await executeAsync()
console.log(data)
0.0.10

11 months ago

0.1.0

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.0.9

11 months ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago