Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
redux-simple-request
Advanced tools
Middleware for Redux to manage requests.
Works in the server as in the browser.
npm install redux-simple-request
// ...
import createApiMiddleware from 'redux-simple-request';
// ...
const apiMiddleware = createApiMiddleware();
export default createStore(
reducer,
applyMiddleware(apiMiddleware)
);
import createApiMiddleware from 'redux-simple-request';
.const apiMiddleware = createApiMiddleware();
. Options can be passed. Check Advanced.applyMiddleware(apiMiddleware)
.The most simple usage with Action Creators.
import { API } from 'redux-simple-request';
const addUsers = (users) => ({
type: 'addUsers',
data: users,
});
const fetchUsers = () => ({
type: API,
url: 'www.my-url.com/users',
onSuccess: (users, dispatch) => {
return dispatch(addUsers(users));
}
});
This example will make a request to www.my-url.com/users
.
Then it will dispatch the addUsers
action with the response data.
Property | Mandatory? | Type | Description |
---|---|---|---|
type | Yes | string | You have to use the API constant that you import from the package |
url | Yes | string | Just give it the url where you want to make your request |
method | No | string | HTTP Method for the request. Default GET |
data | No | object | Data that needs to be sent with the request |
headers | No | object | Headers for the request |
onSuccess | No | function | This function will be called if the request is successful. onSuccess(data, dispatch, getState) . Parameters passed are the response data, dispatcher and getState |
onError | No | function | This function will be called if the request is not successful. onError(error, dispatch, getState) . Parameters passed are the error, dispatcher and getState |
onProgress | No | function | This function will be called before making the request. onProgress(action, dispatch, getState) . Parameters passed are the action, dispatcher and getState |
Plus all the additional properties that can be used with Request
createApiMiddleware()
expects an options object.
Property | Mandatory? | Type | Description |
---|---|---|---|
beforeRequest | No | function | This function will be called for every request. Before the onProgress. beforeRequest(action, dispatch, getState) . Parameters are the action, dispatcher and getState |
Use cases
action.url
.FAQs
Redux Middleware to handle API requests
We found that redux-simple-request demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.