From 153e2ac8541811c39576520f14cf75a7fa418c7b Mon Sep 17 00:00:00 2001 From: Kirill <105653135+rmt-kirill@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:25:04 +0200 Subject: [PATCH] add some more logs --- packages/examples/src/main.ts | 43 ++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/packages/examples/src/main.ts b/packages/examples/src/main.ts index 7e5b77e..9010738 100644 --- a/packages/examples/src/main.ts +++ b/packages/examples/src/main.ts @@ -57,7 +57,9 @@ const basicExample = async () => { }; try { + console.log('Creating catalog:', myCatalogKey); await createCatalog(myNewCatalog); + console.log('Done'); } catch (e: any) { if (e.response?.status === 409) { console.log('Catalog already exists'); @@ -67,7 +69,9 @@ const basicExample = async () => { } try { + console.log('Adding product #1'); await createProduct(myCatalogKey, myNewProducts[0]); + console.log('Done'); } catch (e: any) { if (e.response?.status === 409) { console.log('Product already exists'); @@ -77,7 +81,9 @@ const basicExample = async () => { } try { + console.log('Adding product #2'); await createProduct(myCatalogKey, myNewProducts[1]); + console.log('Done'); } catch (e: any) { if (e.response?.status === 409) { console.log('Product already exists'); @@ -151,7 +157,9 @@ const batchImportExample = async () => { }; try { + console.log('Creating catalog:', myCatalogKey); await createCatalog(myNewCatalog); + console.log('Done'); } catch (e: any) { if (e.response?.status === 409) { console.log('Catalog already exists'); @@ -160,15 +168,38 @@ const batchImportExample = async () => { } } - const { - data: { id: sessionId }, - } = await createImportSession(myCatalogKey, {}); + let sessionId = ''; + try { + console.log('Creating import session for catalog:', myCatalogKey); + const { data } = await createImportSession(myCatalogKey, {}); + sessionId = data.id; + console.log('Import session ID:', sessionId); + } catch (e: any) { + console.log('Error creating import session', `${e}`); + return; + } - await importProducts(myCatalogKey, sessionId, myNewProducts); + console.log( + 'Check session', + await getImportSessionStatus(myCatalogKey, sessionId), + ); - await pollImportSessionStatus(myCatalogKey, sessionId); + try { + console.log('Importing products'); + await importProducts(myCatalogKey, sessionId, myNewProducts); + console.log('Products imported'); + } catch (e: any) { + console.log('Error importing products', `${e}`); + console.log(e.response?.data); + } - console.log('Import session completed'); + try { + console.log('Polling import session status'); + await pollImportSessionStatus(myCatalogKey, sessionId); + console.log('Import session completed'); + } catch (e: any) { + console.log('Error polling import session status', `${e}`); + } const pepperonis = await getProducts( myCatalogKey,