Questions tagged [redux-promise-middleware]

This tag should be used to mark questions related to Redux Promise Middleware, a middleware for Redux that enables async action creators to return promises. The middleware also enables optimistic updates and dispatches pending and rejected/fulfilled actions that describe the promise state.

Redux promise middleware enables robust handling of async action creators in Redux.

Example:

const promiseAction = () => ({
  type: 'PROMISE',
  payload: Promise.resolve(),
})

The middleware can also be combined with Redux Thunk to chain action creators.

Example:

const secondAction = (data) => ({
  type: 'TWO',
  payload: data,
})

const first = () => {
  return (dispatch) => {
    const response = dispatch({
      type: 'ONE',
      payload: Promise.resolve(),
    })

    response.then((data) => {
      dispatch(secondAction(data))
    })
  }
}

Documentation and Help:

Is this wiki out of date? File an issue on GitHub and let us know.

41 questions
0
votes
1 answer

redux-promise-middleware error handling without thunk

We are using redux-promise-middleware and having some difficulty working out what to do about error handling, all errors returned as 400 codes are just handled as 'FULFILLED'. I get that this is probably the correct behaviour but surely there is a…
bubbaspaarx
  • 616
  • 4
  • 15
0
votes
1 answer

Unable to handle error: `middleware is not a function' in redux-promise-middleware?

I am trying to use redux-promise-middleware in my app, but when I am trying to run my app error comes with an error message: 'middleware is not a function or middleware is null'. I tried to use middleware without a function as suggested in redux…
Mohit Yadav
  • 79
  • 3
  • 15
0
votes
1 answer

REDUX THUNK ASYNC AWAIT to return a Promise middleware

I have a problem, i am using redux thunk as my API middleware, and it works fine when it just updates the redux state. However there are parts of my codes that require me to get an response from the request API rather than waiting for it to go…
DarkArtistry
  • 434
  • 1
  • 6
  • 22
0
votes
2 answers

How to create a shorter redux-promise-middleware reducer function that can handle multiple action types?

I've utilized redux-promise-middleware with react and redux to build an application that has several buttons (each will have its own unique ajax request that will update the state accordingly) I started to make the dataReducer for three of the many…
Chris
  • 5,444
  • 16
  • 63
  • 119
0
votes
1 answer

Access wanted data in API?

*apologies as I have posted a similar question earlier but deleted it as this is a better-structured question. Hello! I want to target largeImageURL from the PixaBay API to render within the GridTile in my PhotoResults container. I've configured…
user8860292
0
votes
0 answers

Can´t execute Callback in Redux Thunk after Axios.post and dispatching an action

I wrote a redux thunk so that after making a post request to an API an action gets dispatched and a callback gets executed: import actionTypes from '../actions/actionTypes'; import axios from 'axios'; function postThunk(someValue, callback) { …
0
votes
0 answers

Testing: Getting the payload of the response from a Promise object

In my React-redux app, one of my action creators returns like this: return { type : GET_RESULTS, payload: response }; I am trying to write a test where I just call the action creator externally and mock its arguments since its…
0
votes
1 answer

Mapping Object Data from ReduxPromise

Trying to map an object that was returned from a promise, i am using react-router 4 and redux, redux-promise. the data has been returned as a promise but i cant seem to map it. If i remember correctly, the render() returns the renderBanner function…
Nicholas Ritson
  • 869
  • 4
  • 13
  • 30
0
votes
2 answers

Modifying state with promises

Why do my promises not actually update the state in Redux? I'm using redux-promise-middleware. When I make a call to my API, it goes through the promise steps of _PENDING and _FULFILLED, but the state is never updated to reflect the changes. How do…
0
votes
0 answers

Return types of Action Creators in Redux

I am new to Redux structure.. So far, i have developed an app in which we can render tables details from a list. So one of my action creator is selectTable as below: export function selectTable(table) { var APP = table.app; var TABLE =…
0
votes
2 answers

Redux thunk actions and sharing state

I would like my application to be aware of when async actions are fired and when they complete. The reason for this is that I would like an overall loading state for my applications which sets to true when all async actions have completed. An early…
dougajmcdonald
  • 19,231
  • 12
  • 56
  • 89
1 2
3