react-axios-hooks-graphql-style
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    react-axios-hooks-graphql-style

    A wrapper for axios to behave as graphql request

    NPM JavaScript Style Guide

    Install

    npm install --save react-axios-hooks-graphql-style

    Usage

    useGet

    Behaves like useQuery from graghql

    import React, { Fragment } from 'react'
    
    import { useGet } from 'react-axios-hooks-graphql-style'
    
    
    const App = () => {
      const { loading, data, error } = useGet(
        'https://api.publicapis.org/entries',
        {}, // headers object
        (success: any) => {
          //TODO: Do something here
          console.log(success)
        },
        (error: any) => {
          //TODO: Do something here
          console.log(error)
        }
      )
    
      return (
        <Fragment>
          <div style={{ paddingLeft: 20 }}>
            {loading && <h3>Loading ...</h3>}
            {error && <h3>{error.message}</h3>}
            {data &&
              data?.entries.map((item: any) => (
                <div>
                  <h3>API: {item?.API}</h3>
                  <a href={item?.Link}>URL: {item?.Link}</a>
                  <p>Description: {item?.Description}</p>
                </div>
              ))}
          </div>
        </Fragment>
      )
    }
    
    export default App

    License

    MIT © Mushud

    Keywords

    none

    Install

    npm i react-axios-hooks-graphql-style

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    31.3 kB

    Total Files

    13

    Last publish

    Collaborators

    • mushud