0

I'm in the middle of learning redux and I don't understand why response returns undefined.

But at the same time when I look in the developer tools -> network I can see that I successfully fetched the data I want.

import { onSearchSubmit } from "../apis/unsplash";

export const searchTerm = (term) => async (dispatch) => {
    const response = await onSearchSubmit(term);
    
    dispatch({ type: "SEARCH_TERM", payload: response });
};
import axios from "axios";

export const onSearchSubmit = (term) => {
    axios.get("https://api.unsplash.com/search/photos", {
        params: { query: term },
        headers: {
            Authorization: "Client-ID API_KEY",
        },
    });
};

Marek B
  • 26
  • 2

0 Answers0