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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react_redux_api

v0.1.0

Published

Collection of actions, reducers and helpers for work with API

Readme

react_redux_api_helpers

react_redux_api_helpers is library for eiser using redux store and redux-sagas with request to server. It based on redux-saga and axios packages.

Getting started

Installation

$ npm install --save react_redux_api_helpers

or

$ yarn add react_redux_api_helpers

Usage

init in root saga:

import  *  as  apiHelpers  from  'api';
// some code

 const {modules: { apiWatchRequest },axios: { init },} = apiHelpers;
 //init main routes
 if (process.env.NODE_ENV == 'development') {
   init('http://localhost:3001'); //develop server
} else if (process.env.NODE_ENV == 'production') {
   init('https://translates.goman.live');// production server
}

function* rootSaga(dispatch) {
yield all([
    apiWatchRequest({
        additiveCallback: function*({ showLoaderFlag = true, ...data }) {
            //show loader
            if (showLoaderFlag) {
                yield put(showLoader());
            }

            // add credentials for  request
            const credentials = yield select(authHashSelector);
            if (credentials) {
                set(data, 'headers.Authorization', `${credentials}`);
            }
            return data;
        },
        successCallback: function*(data) {
            yield put(hideLoader());
            if (
                data.config.method === 'put' ||
                data.config.method === 'post' ||
                data.config.method === 'delete'
            ) {
                console.log(data);
                const message = get(data, 'data.message');
                if (message) {
                    yield put(showSuccess({ message }));
                } else {
                    yield put(
                        showSuccess({ message: 'Successful operation.' }),
                    );
                }
            }
        },
        failedCallback: function*(data) {
            const dataStatus = data.status;
            yield put(hideLoader());
            switch (true) {
                case dataStatus === 401:
                    yield call(history.push, '/login');
                    return;
                case dataStatus === 500:
                    yield put(
                        showError({ message: 'Internal server error.' }),
                    );
                    return;
                case dataStatus === 406: {
                    const message = get(
                        data,
                        'response.data.message',
                        'Internal server error.',
                    );
                    yield put(showError({ message }));
                    return;
                }
                case dataStatus === 403: {
                    const message = get(
                        data,
                        'response.data.message',
                        'Internal server error.',
                    );
                    yield put(showError({ message }));
                    return;
                }
                default: {
                    const error = get(data, 'response.data.error');
                    if (
                        typeof error === 'object' &&
                        error.type === 'popup'
                    ) {
                        yield put(showError({ message: error.message }));
                    }
                    return;
                }
            }
        },
    }),
    initModuleSaga(dispatch),
    authSaga(dispatch),
    i18nextModuleSaga(dispatch),
    notificationSaga(dispatch),
]);

}

I recommended use principe Redux-ducks for organization of code , example below.

import * as api_helpers from 'api';

const modules = 'languages';
const {
helpers: { actionCreator, apiSelector },
modules: { ApiRoutes },
} = api_helpers;

const apiRoutes = new ApiRoutes();

export const GET_LANGUAGES_LIST_REQUEST = `${modules}/GET_LANGUAGES_LIST_REQUEST`

export const POST_IMPORT_JSON_REQUEST = `${modules}/POST_IMPORT_JSON_REQUEST`;


export const getTranslatedListRequest = actionCreator(
GET_LANGUAGES_LIST_REQUEST,
);

export const postImportJsonRequest = actionCreator(POST_IMPORT_JSON_REQUEST);


apiRoutes.add(GET_LANGUAGES_LIST_REQUEST, ({ ...params }) => ({
url: `/get-all-keys`,
method: 'get',
params,
}));

apiRoutes.add(POST_IMPORT_JSON_REQUEST, (data) => {
return {
    url: `/import-json`,
    method: 'post',
    data,
    headers: { 'Content-Type': 'multipart/form-data' },
    showLoaderFlag:false

};
});

export const getTranslatedListSelector = apiSelector(GET_LANGUAGES_LIST_REQUEST);

API

init(url)

url - base url for the axios.

ApiRoutes.add(actionType, fn)

actionType - string must end with _REQUEST. For example GET_USER_REQUEST. fn - function for prepare request. For example - `url: /import-json,

 (data) => {
    return {
        url: `/import-json`,
        method: 'post',
        data,
        headers: { 'Content-Type': 'multipart/form-data' },
        showLoaderFlag:false
    }

More information: https://github.com/axios/axios#request-config

apiSelector(actionType,options)