I'm new with react and redux and I was checking a shopping cart app, what if I want to fetch these dummy objects from an external api. I can fetch apis in react but redux makes it a little confusing for me.
productsReducer.js
const INIT_PRODUCTS = [
{id:1, title: 'Watch', description: 'Lorem Ipsum', price: 80, img:''},
{id:2, title: 'Watch', description: 'Lorem Ipsum', price: 50, img:''},
{id:3, title: 'Watch', description: 'Lorem Ipsum', price: 35, img:''}
];
export default function productsReducer(state=INIT_PRODUCTS, action={}) {
function findProductIndex(products, id) {
return products.findIndex((p) => p.id === id)
}
return state;
}