使用redux填充JSON数据以响应表

时间:2018-12-14 16:48:26

标签: json redux react-redux react-table

我在action.js中进行了后期操作,并使用const值进行了映射。我也使用布尔玛编写了表头。但是我不知道到底有多少需要将json数据映射到我的反应表中。

export const getInvoices = (filters) => async (dispatch, getState) => {
dispatch({ type: GET_INVOICES_START });

let response;
try {
    response = await axiosInstance.post("/invoice");
    console.log("response", response);
}
catch (error) {
    return error.response.data;
}

const data = response.data.map(d => ({
    businessUnit: d.biz_unit,
    invoice_num: d.invc_nr,
    order_num: d.co_nr,
    company_name: d.addr_nm,
    address1: d.addr_ln1,
    city: d.city_nm,
    state: d.state_cd,
    zip: d.pstl_cd,
    country: d.ctry_nm,

}));

dispatch({ type: GET_INVOICES_COMPLETE, data });
};
export default getInvoices;`

0 个答案:

没有答案