before merge

This commit is contained in:
Abin Toppo
2026-01-12 15:21:14 +05:30
parent ed11bb479e
commit 360097da70
28 changed files with 4821 additions and 177 deletions
+22 -2
View File
@@ -12,8 +12,27 @@ export const apiCall = async <R, D = {}>(
): Promise<R> => {
try {
const token: any = store.getState().token.token;
console.log("url : ", url)
console.log("token : ", token)
// Generate curl command
let curlCmd = `curl -X ${method.toUpperCase()} "${url}"`;
if (token?.token) curlCmd += ` -H "Authentication: Bearer ${token.token}"`;
curlCmd += ` -H "Content-Type: ${contentType || 'application/json'}"`;
if (data) {
if (contentType === 'multipart/form-data') {
curlCmd += ` --form "${JSON.stringify(data).slice(1,-1).replace(/"/g, '\\"')}"`;
} else {
curlCmd += ` -d '${JSON.stringify(data)}'`;
}
}
if (params) {
curlCmd += ` ${Object.entries(params).map(([k,v]) => `-${k}=${v}`).join(' ')}`;
}
console.log("=== CURL ===");
console.log(curlCmd);
console.log("============");
const response = await axios({
method,
url,
@@ -26,7 +45,8 @@ export const apiCall = async <R, D = {}>(
'Content-Type': contentType || 'application/json',
},
});
console.log("url : ", url)
console.log("Api response",response)
return response.data;
} catch (error: any) {
const errorMessage = error?.response?.data?.error;