New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redux-req

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-req

A redux middleware for handling HTTP requests

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

redux-request

:beginner: A redux middleware for handling HTTP requests

It's based on plain old XHR, though not as fancy as fetch, it simply does the job and there's no need for extra dependencies.

Build Status dependencies npm module codecov.io

Install

npm install redux-req

A quick example

import {ACTION_TYPE} from 'redux-request';

// dispatch an API request
dispatch({
  type: ACTION_TYPE,
  resourceName: 'users'
  url: '/api/users',
  method: 'GET',
  requestType: 'REQUEST_API',
  receiveType: 'RECEIVE_API'
});

once a request is dispatched, the middleware will dispatch an action of the specified request type, you can make a reducer to handle this action, for instance, update the loading state for the resource.

when the request is completed, the middleware will dispatch an event of the specified receive type, similarly, a reducer can be used to handle the response, with a result of either failure or success.

Usage

To dispatch a request middleware aware action, the action should have the following properties:

proptypedescription
typestringrequired should be the type imported (ACTION_TYPE) from the middleware
resourceNamestringthe name of the resource for which you want to send a request, this is necessary for reducers to identify the request
urlstringthe url of the resource
methodstringthe method of the request
payloadanythe request payload

License

MIT

FAQs

Package last updated on 20 May 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc