created transaction list show and create a custom card
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import axios, { AxiosRequestConfig } from "axios";
|
||||
import { Alert, ToastAndroid } from "react-native";
|
||||
import * as Keychain from "react-native-keychain";
|
||||
|
||||
/**
|
||||
@@ -12,7 +13,8 @@ export async function apiCall<T>(
|
||||
url: string,
|
||||
method: "GET" | "POST" | "PUT" | "DELETE" = "GET",
|
||||
data?: any,
|
||||
config?: AxiosRequestConfig
|
||||
config?: AxiosRequestConfig,
|
||||
responseErrorMessage?:string
|
||||
): Promise<T | null > {
|
||||
try {
|
||||
// Get saved credentials from Keychain
|
||||
@@ -41,12 +43,15 @@ export async function apiCall<T>(
|
||||
`Status: ${error.response.status}`,
|
||||
`Data: ${JSON.stringify(error.response.data)}`
|
||||
);
|
||||
if(error.response.status === 400){
|
||||
ToastAndroid.show(error.response.data.message || responseErrorMessage, ToastAndroid.SHORT)
|
||||
}
|
||||
} else if (error.request) {
|
||||
// Request was made but no response received
|
||||
console.error("API Error: No response received", error.request);
|
||||
} else {
|
||||
// Something else went wrong while setting up the request
|
||||
console.error("API Error:", error.message);
|
||||
console.error("API Error:", error);
|
||||
}
|
||||
return null; // return null so the caller can handle it
|
||||
}
|
||||
|
||||
@@ -19,3 +19,4 @@ export const USER_REQUEST = `${BASE_URL}fund/my-requests`
|
||||
export const GROUP_ALL_MEMBER = `${BASE_URL}fund/group/all/member`
|
||||
export const UPDATE_BANK_URL = `${BASE_URL}user/bank/update`;
|
||||
export const CONTRIBUTE = `${BASE_URL}payments/groups/`;
|
||||
export const TRANSACTION = `${BASE_URL}payments/my-transactions`;
|
||||
|
||||
Reference in New Issue
Block a user