Gathering detailed insights and metrics for redux-saga-api-call
Gathering detailed insights and metrics for redux-saga-api-call
Gathering detailed insights and metrics for redux-saga-api-call
Gathering detailed insights and metrics for redux-saga-api-call
redux-saga-call-api
Redux saga for calling api
redux-filtered-pagination
Simple module based on redux/redux-saga which supports call to paginated api, and filter feature
rn-create
react-native cli to create react-native boilerplate component, stateless component, screens, react-navigation boiler plate , integrate redux in component, integrate redux-saga for api call just by using cli.
npm install redux-saga-api-call
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
4 Stars
18 Commits
2 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Jul 04, 2018
Latest Version
0.0.5
Package Id
redux-saga-api-call@0.0.5
Size
28.74 kB
NPM Version
4.1.2
Node Version
7.7.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
redux-saga-api-call
)Simple api call for Redux Saga
Redux Saga api call is a simple method to simplify api calls, instead of calling the api and catch the response and error to dispatch the success and failure action, this call do that for you.
1import apiCall from 'redux-saga-api-call' 2 3// Api method 4const fetchJokeApi = () => fetch('https://api.chucknorris.io/jokes/random') 5 .then(response => response.json()) 6 .then(response => ({response})) 7 .catch(error => ({error})) 8// -> ATTENTION: It's very important to wrap the response and error in objects called response and error, because the call will destructure the response to identify if the call was successfull or not (If you find a way to improve it, please, make a pull request) 9 10... 11// Simplest case 12function* fetchJokeWatcher () { 13 yield takeEvery('FETCH_JOKE', apiCall(fetchJokeApi)) 14} 15// -> {type: 'FETCH_JOKE_START', payload: <whatever was sent to the action>} 16// -> {type: 'FETCH_JOKE_SUCCESS', payload: <server response>} 17... 18 19... 20// Select data from state and send it to apiMethod 21function* fetchJokeWatcher () { 22 yield takeEvery( 23 'FETCH_JOKE', 24 apiCall( 25 fetchJokeApi, 26 { 27 selectFromState: state => state.userPreferences 28 } 29 ) 30 ) 31} 32// -> fetchJokeApi({payload: <payload sent to action>, selectedData: <userPreferences>) 33... 34 35... 36// Transform response and error data 37function* fetchJokeWatcher () { 38 yield takeEvery( 39 'FETCH_JOKE', 40 apiCall( 41 fetchJokeApi, 42 { 43 transformResponse: response => response.filter(joke => !joke.includes('Bruce lee')), 44 transformError: error => `Error: ${error}` 45 } 46 ) 47 ) 48} 49// -> {type: 'FETCH_JOKE_SUCCESS', payload: <All jokes that doesn't include 'Bruce lee' on it>} 50// -> {type: 'FETCH_JOKE_FAILURE', payload: 'Error: <the error that the server returned>'} 51...
Call the method like this:
apiCall(apiMethod, options)
apiMethod
should be a thenable object
selectFromState
: A function that receives the Redux state, then the apiMethod
will receive a merged object between this selectors and the action payloadtransformResponse
: Once the apiMethod
resolved, the response will be piped through this function and the result will be dispatched as {ACTION_NAME}_SUCCESS
(If this is not present, the raw result will be dispatched instead)transformError
: Once the apiMethod
rejected, the error will be piped through this function and the result will be dispatched as {ACTION_NAME}_FAILURE
(If this is not present, the raw error will be dispatched instead)To reduce the boilerplate in most basic api calls
1yarn add redux-saga-api-call 2// or 3npm install --save redux-saga-api-call
1// jest tests 2yarn test 3// jest coverage 4yarn cover
Simply create a pull request :)
This project is based on an idea of @pablen about reducing boilerplate in Redux Saga.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
62 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More