
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
redux-api-middleware-native
Advanced tools
Api middleware for redux compatible with native and web apps.
npm install --save redux-api-middleware-native
import { createStore, applyMiddleware, combineReducers } from 'redux';
import apiMiddleware from 'redux-api-middleware-native';
import reducers from './reducers';
const reducer = combineReducers(reducers);
const initialState = {};
const store = createStore(reducer, initialState, applyMiddleware(
apiMiddleware,
));
import { CALL_API } from 'redux-api-middleware-native';
function action() {
return {
[CALL_API]: {
endpoint: 'http://www.example.com/resource',
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: {
'username' : 'npm-user',
'password' : 'test'
},
types: ['SUCCESS', 'FAILURE', 'ERROR'],
meta: {
id: 'Data to reducer'
}
}
}
}
import { CALL_API } from 'redux-api-middleware-native';
function action() {
return {
[CALL_API]: {
endpoint: 'http://www.example.com/resource',
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: {
'username' : 'npm-user',
'password' : 'test'
},
types: [{
type: 'SUCCESS',
payload: (action, state, res) => {
return res.json().then((json) => {
// Inserting a header in response
json.token = res.headers.get('Authorization');
return json;
});
},
meta: (action, state) => {
return action.meta;
}
}, 'FAILURE', 'ERROR'],
meta: {
id: 'Data to reducer'
}
}
}
}
Action {
type = types[0]
payload = JSON parsed response
error = false
meta = Any data that you sent
}
Type failure means your request not get HTTP status code 200 without any other errors.
Action {
type = types[1]
payload = JSON parsed response
error = true
meta = Any data that you sent
}
Type error means we got exception on some point of code (ex. response parsing).
Action {
type = types[2]
payload = ERROR object
error = true
meta = Any data that you sent
}
FAQs
Api middleware for React Native.
We found that redux-api-middleware-native 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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.