Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
jsonapi-redux-data
Advanced tools
Library that makes integration of jsonapi with redux effortless and easy
JsonApi Redux data is a one stop shop for all your jsonapi needs! Provides methods to make your API call and formats and updates data in the redux store. It joins all of your relations so that accessing it is as easy as entity.relationship
For example if you made an API call to base-url/tasks?include=list
, you can access your relationships as easily as tasks[index].list
Provides methods to make api calls to your JSONApi compliant backend and updates the redux store as well.
Combines the data so it is easily accessible
Setup in 3 easy steps
yarn add jsonapi-redux-data
OR
npm i jsonapi-redux-data
Update the reducers / rootReducers like this
...
import { jsonApiReducer } from 'jsonapi-redux-data'
...
const rootReducer = combineReducers({
...,
api: jsonApiReducer,
...
})
...
Create the api client preferrably in the app.js
...
import { createApiClientWithTransform } from 'jsonapi-redux-data'
...
// Create redux store with history
const initialState = {};
const store = configureStore(initialState, history);
...
createApiClientWithTransform('<base-url>', store)
...
Make api call easily and from anywhere
...
import { getApi } from 'jsonapi-redux-data'
...
getApi({ pathname: '<pathname>', include: '<include-string>' })
...
getApi({
pathname: 'tasks',
include: 'lists',
levelOfNesting: 3
});
Invoking this method will
base-url/tasks
SUCCESS_API
Make a get request and add api response to the redux store.
/**
* @param {} requestPayload: {
* include: object
* filter: object,
* pathname: String,
* levelOfNesting: number,
* transformList: object,
* id: String
* }
* @param {} api: Custom Api Client instead of the latest created api client
* @param {} axios: Special axios config
**/
function getApi (requestPayload, api, axiosConfig)
Make a post request and add api response to the redux store
/**
* @param {} requestPayload: {
* include: object
* filter: object,
* pathname: String,
* levelOfNesting: number,
* transformList: object,
* postData: object
* }
* @param {} api: Custom Api Client instead of the latest created api client
* @param {} axios: Special axios config
*/
function postApi (requestPayload, api, axiosConfig)
Make a patch request and add api response to the redux store
/**
*
* @param {} requestPayload: {
* include: object
* filter: object,
* pathname: String,
* levelOfNesting: number,
* transformList: object,
* patchData: object
* }
* @param {} api: Custom Api Client instead of the latest created api client
* @param {} axios: Special axios config
*
* */
function patchApi (requestPayload, api, axios)
Make a delete request and add api response to the redux store
/**
*
* @param {} requestPayload: {
* pathname: String,
* id: String
* }
* @param {} api: Custom Api Client instead of the latest created api client
* @param {} axios: Special axios config
*
* */
function deleteApi (requestPayload, api, axios)
GET HTTP REQUEST, uses the apisauce.get underneath the hood.
/**
* @param {} pathname: the endpoint path
* @param {} include: the jsonapi include string
* @param {} filter: the jsonapi filter string
* @param {} id: the id of the GET request.
* @param {} api: default is getLatestApiClient()
* @param {} axiosConfig: custom axiosConfig for this request
*/
function getRequest (pathname, include, filter, id, api, axiosConfig)
POST HTTP REQUEST, uses the apisauce.get underneath the hood.
/**
*
* @param {} pathname: the endpoint path
* @param {} include: the jsonapi include string
* @param {} filter: the jsonapi filter string
* @param {} postData: request body
* @param {} api: default is getLatestApiClient()
* @param {} axiosConfig: custom axiosConfig for this request
*/
function postRequest (pathname, include, filter, postData, api, axiosConfig)
PATCH HTTP REQUEST, uses the apisauce.get underneath the hood.
/**
* @param {} pathname
* @param {} include: the jsonapi include string
* @param {} filter: the jsonapi filter string
* @param {} id: the id of the PATCH request.
* @param {} patchData: request body
* @param {} api: default is getLatestApiClient()
* @param {} axiosConfig: custom axiosConfig for this request
*/
function patchRequest (pathname, include, filter, id, patchData, api,axiosConfig)
DELETE HTTP REQUEST, uses the apisauce.get underneath the hood.
/**
* @param {} pathname
* @param {} id: the id of the DELETE request.
* @param {} api: default is getLatestApiClient()
* @param {} axiosConfig: custom axiosConfig for this request
*/
function deleteRequest (pathname, id, api, axiosConfig)
FAQs
Library that makes integration of jsonapi with redux effortless and easy
The npm package jsonapi-redux-data receives a total of 11 weekly downloads. As such, jsonapi-redux-data popularity was classified as not popular.
We found that jsonapi-redux-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.