Registry / devops / saga-fetch

saga-fetch

JSON →
library1.3.14jsnpmunverified

saga-fetch is a Redux Saga helper that simplifies fetching data by dispatching start, success, error, and fulfill actions. It wraps async methods like window.fetch or axios, handling the boilerplate of action dispatching in saga workers. Version 1.3.14 is current; it's stable with no recent updates. Requires redux-saga >=1.0.2. Compared to alternatives like redux-saga-routines, it focuses solely on fetch workers with explicit action mapping.

npm install saga-fetch
INSTALL
IMPORT
SIG · SAGA-FETCH
S
saga-fetch
devopsjavascriptv1.3.14
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetchWorker
import fetchWorker from 'saga-fetch'
const fetchWorker = require('saga-fetch');
Default export; CommonJS works but ESM is preferred.
default import (any name)
import fetch from 'saga-fetch'
import { fetchWorker } from 'saga-fetch'
Default export, not a named export. Common mistake to destructure.
default import with ES Modules
import fetch from 'saga-fetch'
ESM is supported; bundles correctly.

Demonstrates basic usage with fetch, fork, and action creators for start/success/error/fulfill.

import { fork, takeEvery } from 'redux-saga/effects'; import fetchWorker from 'saga-fetch'; const apiFetch = ({ payload: { id } }) => fetch(`/api/item/${id}`).then(res => res.json()); function* myWorker(action) { yield fork(fetchWorker, { action, method: apiFetch, start: (payload) => ({ type: 'FETCH_START', payload }), success: (data) => ({ type: 'FETCH_SUCCESS', payload: data }), error: (err) => ({ type: 'FETCH_ERROR', payload: err }), fulfill: (payload) => ({ type: 'FETCH_FULFILL', payload }), }); } function* watcher() { yield takeEvery('FETCH_REQUEST', myWorker); }
Debug
Known issues
breakingAction types for start/success/error/fulfill must be provided as actions (objects with type), not just type strings.
fix
Pass action creators that return action objects, not type strings.
affects: >=1.0.0
gotchaThe method parameter must receive a function that accepts the action and returns a promise (fetch or axios).
fix
Ensure method takes `{ payload }` and returns promise, e.g., `({ payload }) => fetch(url)`.
affects: >=1.0.0
gotchafulfill action is dispatched only if provided; it runs after success or error.
fix
Provide a fulfill action if you need to reset loading state after completion.
affects: >=1.0.0
deprecatedNo longer maintained; last update 4 years ago. May not work with newer redux-saga versions.
fix
Consider alternatives like redux-saga-routines or custom saga code.
affects: >=1.3.14
Errors
Common errors & fixes
Error: Actions must be plain objects. Use custom middleware for async actions.
Passing a function to dispatch instead of an action object.
fix
Ensure start, success, error, fulfill are action creators returning plain objects, e.g., `(payload) => ({ type: 'ACTION', payload })`.
Uncaught TypeError: method is not a function
Passing a non-function as method option.
fix
Pass a function that returns a promise: `({ payload }) => fetch(url)`.
redux-saga: Uncaught TypeError: Cannot read property 'type' of undefined
Missing required option (action, method, start, success, error).
fix
Ensure all required options are provided: action, method, start, success, error.
Upgrade
Version history
1.3.14latest on npm
Audit
Dependencies
redux-sagaoptionalPeer dependency for saga effects (fork, takeEvery, etc.)
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
saga-fetch — npm install saga-fetch · libregistry