StephenGrider / ReduxSimpleStarter

Starter pack for an awesome Udemy course
MIT License
3.56k stars 4.65k forks source link

My post values are not passing to component #233

Open nagarajach opened 6 years ago

nagarajach commented 6 years ago

Hello MR StephenGrider,

My post values are not passing to component. But from my network url I am able to see the data: This is my Url 👍 http://reduxblog.herokuapp.com/api/posts?key=Hello123 Response: [{"id":233702,"title":"Test","categories":"Test","content":"Test"},{"id":233700,"title":"Test","categories":"Test","content":"Test"},{"id":233699,"title":"Test","categories":"Test","content":"Test"}]

JUst I tried to get action payload data in 'reducer_posts.js' file. added console.log

import _ from 'lodash'; import { FETCH_POSTS } from '../actions';

export default function (state = {},action) {
console.log(action.payload); switch (action.type) {
case FETCHPOSTS:
return
.mapKeys(action.payload.data, 'id');

    default:
        return state;
}

}

image image

First 3 times getting undefined and 4th time getting promise data . Could you please help me to get resolve this issue.

Thank You

nagarajach commented 6 years ago

If I use any other api url also I am getting same error. Tried with different API URL too. https://jsonplaceholder.typicode.com/users Might be some problem in my promise code. Please help me .