我有以下行动创作者:
export const fetchgadata = VIEW_ID => (dispatch) => {
dispatch({
type: 'FETCH_DATA_REQUEST',
isFetching:true,
error:null
});
return axios.get("http://localhost:3000/gadata", {
params: {
id: VIEW_ID
}
}).then(response => {
dispatch({
type: 'FETCH_DATA_SUCCESS',
isFetching: false,
data: response.data.rows.map( ([x, y]) => ({ x, y }) )
});
})
.catch(err => {
dispatch({
ype: 'FETCH_DATA_FAILURE',
isFetching:false,
error:err
});
console.error("Failure: ", err);
});
};
export function onSetTimeRange(timerange) {
return {
type: 'SET_TIME_RANGE',
timerange
}
}
我想要做的是将VIEW_ID
值传递给我的axios param。所以从这里... const fetchgadata = VIEW_ID => (dispatch) => { ...
到这里...return axios.get("http://localhost:3000/gadata", { params: { id: VIEW_ID }
}).then(response => ...
我应该如何编写代码?
感谢。