Gathering detailed insights and metrics for @domtwlee/redux-api-actions
Gathering detailed insights and metrics for @domtwlee/redux-api-actions
Gathering detailed insights and metrics for @domtwlee/redux-api-actions
Gathering detailed insights and metrics for @domtwlee/redux-api-actions
npm install @domtwlee/redux-api-actions
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
74 Commits
21 Branches
2 Contributors
Updated on Feb 08, 2020
Latest Version
2.1.1
Package Id
@domtwlee/redux-api-actions@2.1.1
Unpacked Size
17.90 kB
Size
5.27 kB
File Count
8
NPM Version
6.9.0
Node Version
10.16.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Redux middleware for dispatching api actions.
Standardises the way actions are handled for api calls and cuts down on boilerplate.
npm install @domtwlee/redux-api-actions
To enable apiActions:
import { createStore, applyMiddleware } from 'redux';
import { apiActions } from '@domtwlee/redux-api-actions';
import rootReducer from './reducers/index';
const store = createStore(
rootReducer,
applyMiddleware(apiActions)
);
Dispatch an action suffixed with "REQUEST" in its type and add the relevant apiCall field in meta to trigger the middleware.
export const getConsumersRequest = (roleType: string) => ({
type: "GET_TODOS_REQUEST",
meta: {
apiCall: () => fetch('example.com/todos'),
},
});
You can use whatever promise-based API for fetching resources.
This will automatically generate GET_TODO_SUCCESS
and GET_TODO_FAILURE
action types, and dispatch the appropriate action upon resolve/reject of the fetch promise.
All the actions objects follow flux-standard-actions https://github.com/redux-utilities/flux-standard-action.
A utility function is included to generate the appropriate action types that you can then use for your actions/reducers.
const [
GET_TODOS_REQUEST,
GET_TODOS_SUCCESS,
GET_TODOS_FAILURE,
] = createAsyncActionTypes('consumers', 'GET_CONSUMERS');
// Returns ['consumers/GET_TODOS_REQUEST', 'consumers/GET_TODOS_SUCCESS', 'consumers/GET_TODOS_FAILURE']
function todoReducer(state = initialState, action) {
switch (action.type) {
case GET_TODO_REQUEST: {
return {
...state,
loading: true,
};
}
case GET_TODO_SUCCESS: {
return {
...state,
loading: false,
todos: action.payload,
};
}
case GET_TODO_FAILURE: {
return {
...state,
loading: false,
error: action.payload,
};
}
default:
return state;
}
}
Finally, you have the option to include a normalizr schema to shape the json response from your fetch before the success action is dispatched. https://github.com/paularmstrong/normalizr
import { schema } from 'normalizr';
const todoSchema = new schema.Entity('todos', {}, { idAttribute: 'todoId' });
const todoListSchema = [todoSchema];
export const getConsumersRequest = (roleType: string) => ({
type: "GET_TODOS_REQUEST",
meta: {
apiCall: () => fetch('example.com/todos'),
schema: todoListSchema,
},
});
This project is licensed under the MIT License - see the LICENSE.md file for details
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
58 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More