0

I have an action that looks like this:

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
    };
}

here is my reducer for this action:

import { GET_LOCATIONS } from '../actions/skyscannerActions.js';

export default function(state=[], action){
    switch (action.type) {
        case GET_LOCATIONS: 
            return [action.payload.data]; 
    }
    return state;
}

I cant get the data since my payload is not the response but request, how can I get the response.data from my reducer?

is that eeven possible?

S. N
  • 3,456
  • 12
  • 42
  • 65

0 Answers0