Socket
Socket
Sign inDemoInstall

redux-saga-service-wrapper

Package Overview
Dependencies
20
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    redux-saga-service-wrapper

Redux Saga Service Wrapper


Version published
Maintainers
1
Created

Readme

Source

Redux-Saga Service Wrapper

Redux-Saga Service Wrapper is an approach that allows you to manage your services with only one Saga and call separate action accordingly, the rest is under your control! Perform anything you want.

Yes, you can use serviceWrapperSaga for your all service calls and manage your response for error and success cases. We use Map object for handling errors.

export const endpoints = {
  filter: () => `anyServicePath`
}
export const getService: () => Promise<GetServiceResponse> = () => axios.get(endpoints.filter());
export const postService: (body: any) => Promise<PostServiceResponse> = (body: any) => axios.post(endpoints.filter(), body);
 

GET Service Call



function* getServiceSaga({ searchQuery }) {
  try {
    const { filter } = yield serviceWrapperSaga(getService)
    //....
  } catch (e) {
    console.log(e);
  }
}

POST Service Call


function* postServiceSaga({ searchQuery }) {
  try {
    const { filter } = yield serviceWrapperSaga(postService, {test: 'TEST'})
    //....
  } catch (e) {
    console.log(e);
  }
}

Handling Errors

Loading .. ;)

Keywords

FAQs

Last updated on 11 Oct 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc