import { transactionUrl } from "./IlinkConstants"; import { store } from "../redux/store"; import axios from "axios"; import { fetchWalletHistoryPending, fetchWalletHistorySuccess, fetchWalletHistoryError } from "../redux/actions/WalletActions"; const getWalletTransactionHistory = (walletID) => { const auth = store.getState().authKeyReducer; const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : ''; return dispatch => { dispatch(fetchWalletHistoryPending()); axios({ url: `${transactionUrl}/${walletID}`, method: 'GET', headers: { 'Authorization': authKey } }) .then(response => { console.log(response); dispatch(fetchWalletHistorySuccess(response)); }) .catch(error => { console.log(error); dispatch(fetchWalletHistoryError(error.message)); if (error.response) dispatch(fetchWalletHistoryError(error.response)); else if (error.request) dispatch(fetchWalletHistoryError(error.request)) else dispatch(fetchWalletHistoryError(error.message)) }); } } export default getWalletTransactionHistory;