Options
All
  • Public
  • Public/Protected
  • All
Menu

retrievejs

Index

Type aliases

ApiRequester

ApiRequester: function

Type declaration

    • (config?: AxiosRequestConfig, params?: undefined | __type): AxiosPromise
    • Parameters

      • Optional config: AxiosRequestConfig
      • Optional params: undefined | __type

      Returns AxiosPromise

Log

Log: function

Type declaration

    • (val: string): void
    • Parameters

      • val: string

      Returns void

NetworkState

NetworkState: object

Type declaration

  • data: null | any
  • failed: boolean
  • isFetching: boolean

QueryType

QueryType: function

Type declaration

    • (func: ApiRequester, propName?: undefined | string, requestConfig?: AxiosRequestConfig, params?: undefined | object): function
    • Parameters

      • func: ApiRequester
      • Optional propName: undefined | string
      • Optional requestConfig: AxiosRequestConfig
      • Optional params: undefined | object

      Returns function

        • (WrappedComponent: React.SFC | ComponentClass): React.SFC | ComponentClass
        • Parameters

          • WrappedComponent: React.SFC | ComponentClass

          Returns React.SFC | ComponentClass

Variables

Const DELETE

DELETE: string = "delete"

Const FAILED

FAILED: "failed" = "failed"

Const GET

GET: string = "get"

Const HEAD

HEAD: string = "head"

Const LOAD

LOAD: "load" = "load"

Const OPTIONS

OPTIONS: string = "options"

Const POST

POST: string = "post"

Const PUT

PUT: string = "put"

Const RETRIEVEJS_PREFIX_ACTIONS

RETRIEVEJS_PREFIX_ACTIONS: string = "retrievejs/api/"

Const SUCCESS

SUCCESS: "success" = "success"

Const logPrefix

logPrefix: string = "RETRIEVEJS: "

Functions

Const createApi

  • Creates an api object which contains functions depending on the endpoint object passed in the 1st parameter.

    Example (es imports)

    import { createApi } from 'retrievejs';
    const endpoints = {
    getMock: { path: 'http://www.mocky.io/v2/5aab93182e00004900138dd4', method: 'get' }
    };
    const api = createApi(endpoints);
    // => api.getMock().then((response) => console.log(response))
    

    Parameters

    Returns Api

Const errorLog

  • errorLog(val: string): void
  • Parameters

    • val: string

    Returns void

Const normalLog

  • normalLog(val: string): void
  • Parameters

    • val: string

    Returns void

Const query

  • query(func: ApiRequester, propName?: undefined | string, requestConfig?: undefined | AxiosRequestConfig, params?: undefined | object): (Anonymous function)
  • A query HOC for doing a request when the passed component is mounted.

    Refresh example

     ...
     // refresh request:
     this.props.myRequest.refreshRequest()
     ...
    

    Example (es imports)

    import { query } from 'retrievejs';
    const enhance = query(api.getMockData, 'myRequest')
    export const MyComponent = enhance((props) => <pre>{JSON.stringify(props, null, 4)}</pre>)
    

    Data structure passed to props

    const MyComponent = (props) => {
         // props.myRequest.request
         //      => axios request object
         // props.myRequest.isFetching
         //      => whether or not we're currently fetching a resource
         // props.myRequest.failed
         //      => if the request failed, if yes, equals to true
    }
    

    Parameters

    • func: ApiRequester
    • Default value propName: undefined | string = "query"
    • Default value requestConfig: undefined | AxiosRequestConfig = {}
    • Default value params: undefined | object = {}

    Returns (Anonymous function)

Const reducer

Const warnLog

  • warnLog(val: string): void
  • Parameters

    • val: string

    Returns void

Generated using TypeDoc