我有一个看起来像这样的动作:
import axios from 'axios';
export const GET_LOCATIONS = 'GET_LOCATIONS';
export function fetchLocals() {
const request = axios.get('http://localhost:3001/api')
.then(function(response) {
console.log(response.data)
})
.catch(function (error) {
console.log(error);
});
return {
type: GET_LOCATIONS,
payload: request
};
}
这是我的减速器:
import { GET_LOCATIONS } from '../actions/skyscannerActions.js';
export default function(state=[], action){
switch (action.type) {
case GET_LOCATIONS:
return [action.payload.data];
}
return state;
}
由于我的有效负载不是响应而是请求,我无法获取数据,如何从reducer获取response.data?
可能吗?