npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@salsita/react-api

v1.0.0

Published

## Install

Downloads

8

Readme

react-api

Install

Install this package with npm

npm i @salsita/react-api

or yarn

yarn add @salsita/react-api

API

Modules

Classes

Constants

Functions

ApiActions

ApiActions.apiError(errorType, errorReason) ⇒ Action

Saves API error

Kind: static method of ApiActions

| Param | Type | Description | | --- | --- | --- | | errorType | string | Type of the error | | errorReason | string | Reason of the error |

ApiActions.startLoading() ⇒ Action

Sets the global loading indicator on

Kind: static method of ApiActions

ApiActions.stopLoading() ⇒ Action

Sets the global loading indicator off

Kind: static method of ApiActions

ApiSelectors

ApiSelectors.getError(state) ⇒ string | null

Returns the latest API error type

Kind: static method of ApiSelectors
Returns: string | null - The latest API error type

| Param | Type | Description | | --- | --- | --- | | state | RootState | The root state |

ApiSelectors.isLoading(state) ⇒ boolean

Returns true if a loading is in progress

Kind: static method of ApiSelectors
Returns: boolean - True if a loading indicator is in progress, false otherwise

| Param | Type | Description | | --- | --- | --- | | state | RootState | The root state |

ApiError

The base class for API errors

Kind: global class

apiError.constructor(type, reason)

Creates an API error

Kind: instance method of ApiError

| Param | Type | Description | | --- | --- | --- | | type | string | Type of the error | | reason | string | Reason of the error |

apiError.getReason() ⇒ string

Get the error reason

Kind: instance method of ApiError
Returns: string - The error reason

apiError.getType() ⇒ string

Get the error type

Kind: instance method of ApiError
Returns: string - The error type

BusinessValidationError

The class for business validation error

Kind: global class

businessValidationError.constructor(reason)

Creates a business validation error

Kind: instance method of BusinessValidationError

| Param | Type | Description | | --- | --- | --- | | reason | string | The error reason |

HTTP_CONFLICT

The error code for HTTP conflict

Kind: global constant

apiReducer(state, action) ⇒ ApiState

The reducer of the API module

Kind: global function

| Param | Type | Description | | --- | --- | --- | | state | ApiState | The state of the API module | | action | Action | A redux action |

withErrorHandling(saga, ...args)

Wraps saga into try/catch block catching all the ApiErrors and translating them to API_ERROR actions.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | saga | Generator | API call saga which may throw an ApiError | | ...args | any | Arguments to be passed to the saga |

withLoadingIndicator(saga, ...args)

Wraps saga into start/stop loading actions

Kind: global function

| Param | Type | Description | | --- | --- | --- | | saga | Generator | A long running saga | | ...args | any | Arguments to be passed to the saga |

wrapApiCall(call) ⇒ function

Wraps function with try/catch block to catch all the API errors and translate them to according exceptions.

Kind: global function
Returns: function - Wrapped API call function

| Param | Type | Description | | --- | --- | --- | | call | function | A function calling an API client and returning promise |

ApiErrorToast()

A simple component that shows an error toast message

Kind: global function

ApiLoader()

A simple component that shows a loading indicator

Kind: global function