0

In my react app I want to pass my data (transactions) into redux. To do that I've created this reducer:

import axios from 'axios'

let data = axios.get('http://localhost:3001/transactions')
  .then(res => {
    return res.data
  })

export default data

But when I get data to pass it to combineReducers I get this instead of an array that can be passed and used by components

Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
__proto__
:
Promise
[[PromiseStatus]]
:
"resolved"
[[PromiseValue]]
:
Array(10)

How can I extract that Array(10) ?

Le garcon
  • 7,197
  • 9
  • 31
  • 46
  • Via `promise.then(result => {/*do something with result*/})`. Promises do **not** make asynchronous process synchronous. – Felix Kling Nov 06 '17 at 23:06
  • And that's not a reducer. You should do this in an action creator (probably using redux thunk) and update the state in a reducer. – Rick Jolly Nov 06 '17 at 23:16
  • check out this link, here it is more clearly explained: https://stackoverflow.com/questions/44718910/react-native-async-await-does-not-work – Roman Habibi Nov 07 '17 at 00:47

0 Answers0