Use stringify to show nested objects

This commit is contained in:
IshaVenikar 2024-07-29 17:14:18 +05:30
parent b06e07b0f8
commit a17f060f4d
2 changed files with 8 additions and 7 deletions

View File

@ -22,6 +22,7 @@
},
"scripts": {
"build": "tsc",
"start": "node dist/index.js"
"start": "node dist/index.js",
"cli": "node dist/cli/index.js"
}
}

View File

@ -5,13 +5,13 @@ import { sumsubAxios } from '../../../utils';
dotenv.config();
export const command = 'applicant-details';
export const desc = 'Get applicant details.';
const SUMSUB_BASE_URL = 'https://api.sumsub.com';
const SUMSUB_APP_TOKEN = process.env.SUMSUB_APP_TOKEN || '';
export const command = 'applicant-details [applicantId]';
export const desc = 'Get applicant details.';
export const builder = (yargs: any) => {
return yargs.positional('applicantId', {
describe: 'The applicant ID to query',
@ -39,7 +39,7 @@ function getApplicantDetails (applicantId: string | number) {
}
export const handler = async (argv: Arguments) => {
const applicantId = argv._[2];
const applicantId = argv.applicantId as string;
if (!applicantId) {
console.error('Applicant ID is required');
@ -47,7 +47,7 @@ export const handler = async (argv: Arguments) => {
try {
const response = await sumsubAxios(getApplicantDetails(applicantId));
console.log('Applicant Data:', response.data);
console.log('Applicant Data:', JSON.stringify(response.data, null, 2));
} catch (error: any) {
console.error('Failed to fetch applicant data:', error.response ? error.response.data : error.message);
}