Questions tagged [redux-promise]

48 questions
1
vote
1 answer

Redirect user with React-Router 4 and Redux-Promise

I have a simple use case which within the React-Router 4 and Redux environment seems pretty difficult to achieve. When a user logs in, a redux promise action is fired off which returns an API token, expiry date and some other info. When and if the…
1
vote
1 answer

PHP Script Cannot Receive Data from axios's Request in Redux Action Function

I want to sent some data to a php script with the use of redux and promise as if the following. export function fetchFileContent() { return { type: "FETCH_FILECONTENT", payload: axios.post("/api/ide/read-file.php", { …
Casper
  • 4,435
  • 10
  • 41
  • 72
0
votes
1 answer

Enabling both redux-promise and redux-saga middlewares appears to cause problems

I'm using an ejected create-react-app codebase and trying to setup both redux-saga and redux-promise middlewares. However redux-saga seems disabled no matter how I approach it or will sometimes report an error indicating that applyMiddleware hasn't…
mikejw
  • 183
  • 1
  • 2
  • 12
0
votes
3 answers

Proper way to handle errors in redux using redux-promise

I'm trying "redux-promise". When there's no error in the flow, my code works properly. But, let's say that the API is down or I have a typo in the URL. In those cases, I expect to handle the error in the proper way. This is the API:…
Peter
  • 2,004
  • 2
  • 24
  • 57
0
votes
2 answers

TypeError: this.props.weather is undefined

I'm working on an app that will help me fetch a five day weather forecast for any city using openweathermap.org, However, i get the above error in the browser whenever i call a function renderWeather in the WeatherList container as shown in my code…
lasabahebwa
  • 281
  • 2
  • 14
0
votes
0 answers

Redux - Error: Actions must be plain objects. Use custom middleware for async actions. redux-promise

Now after resolving the issue here REDUX - How to import an API function returning Promise and add it into payload on action creator I have the following error: Error: Actions must be plain objects. Use custom middleware for async actions. ▶ 3…
maciejk77
  • 89
  • 2
  • 8
0
votes
2 answers

Redux-promise not resolving a promise when in the action there is a number

I am currently developing an application that is a copy of Instagram. It works with React-Redux, calls an external API via axios to fetch photos that are actually blog posts. I need to also pass the amount of likes (so 0) for each one, that I am…
llievredemars
  • 170
  • 2
  • 15
0
votes
2 answers

React + Redux + Axios not loading component after actions is created

I am trying to consume an API that I have created, I have followed a code that I have used before but when the component is loaded, as the json list is empty, it shows and empty list, I can see in the log that the list is being loaded afterwards but…
Cheluis
  • 1,402
  • 3
  • 22
  • 51
0
votes
1 answer

using redux-thunk creates undefined error while Promise work just fine

here is my reducer: export default function(state=[], action){ switch (action.type) { case FETCH_PLACES: return [action.payload.data]; } return state; } and here is my flight container: import React, { Component }…
S. N
  • 3,456
  • 12
  • 42
  • 65
0
votes
1 answer

React-redux project - chained dependent async calls not working with redux-promise middleware?

I'm new to using redux, and I'm trying to set up redux-promise as middleware. I have this case I can't seem to get to work (things work for me when I'm just trying to do one async call without chaining) Say I have two API calls: 1) getItem(someId)…
CustardBun
  • 3,457
  • 8
  • 39
  • 65
0
votes
1 answer

Why is API request returning [object Object] in the reducer's action value?

I'm trying to make a search app, with the Giphy API, redux and axios, but I think I'm going wrong somewhere with the API request to grab all the search results from the API. I make an API request using an action, which is caught by a reducer, but…
user74843
  • 701
  • 2
  • 10
  • 28
0
votes
1 answer

reducer isn't triggered (redux-promise with axios)

I'm trying to make an api call in action with axios and pass the results of it to the reducer. Though action is triggered, reducer isn't. And I can't understand why. Here's the component that should make api call before mounting import React, {…
Vel Green
  • 67
  • 8
0
votes
1 answer

How to write tests for async actions in a project that uses redux-promise and axios?

My team recently started working on a project that uses redux-promise. The payload in each action is an axios call, like this: function fetchUsers() { return { type: actionTypes.FETCH_USERS, payload: axios.post('users') …
Joe Maffei
  • 1,855
  • 1
  • 15
  • 18
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
2 answers

Redux async action triggered after request finished. Why?

I have problem with my async action. I would like to set 'loading' state to true when action fetchPosts() is called and 'loading' state to false when action fetchPostsSuccess() or fetchPostsFailiure(). With my current code it works almost fine…