diff --git a/postman-script/upload-script.js b/postman-script/upload-script.js index a825a0c..535aab4 100644 --- a/postman-script/upload-script.js +++ b/postman-script/upload-script.js @@ -114,16 +114,24 @@ async function uploadCollection() { async function main() { try { const response = await getCollections(); - for (let collection of response.collections) { - if (collection.name.includes(args[3])) { - console.log(collection); - const response = await deleteCollection(collection.id); - console.log(response); - } + if (!response.collections) { + console.log(response) + throw new Error("Postman API threw an error"); } const upload = await uploadCollection(); + if (!upload.collection) { + console.log(upload) + throw new Error("Postman API threw an error"); + } console.log(upload); fs.writeFileSync('postman/links/' + args[3].toLowerCase() + '-link.txt','https://god.gw.postman.com/run-collection/' + upload.collection.uid + '?action=collection%2Ffork&collection-url=entityId%3D' + upload.collection.uid + '%26entityType%3Dcollection%26workspaceId%3D80af54be-a333-4712-af5e-41aa9eccbdd0') + for (let collection of response.collections) { + if (collection.name.includes(args[3])) { + console.log(collection); + const response = await deleteCollection(collection.id); + console.log(response); + } + } } catch (error) { console.error(error); } diff --git a/postman/links/v3-link.txt b/postman/links/v3-link.txt index c9ec423..2aad2e6 100644 --- a/postman/links/v3-link.txt +++ b/postman/links/v3-link.txt @@ -1 +1 @@ -https://god.gw.postman.com/run-collection/23226990-6666a82e-d785-4fa0-b9f8-c1a3a63533e9?action=collection%2Ffork&collection-url=entityId%3D23226990-6666a82e-d785-4fa0-b9f8-c1a3a63533e9%26entityType%3Dcollection%26workspaceId%3D80af54be-a333-4712-af5e-41aa9eccbdd0 \ No newline at end of file +https://god.gw.postman.com/run-collection/23226990-0f1c5334-ce2e-4b32-b516-cff77c38097f?action=collection%2Ffork&collection-url=entityId%3D23226990-0f1c5334-ce2e-4b32-b516-cff77c38097f%26entityType%3Dcollection%26workspaceId%3D80af54be-a333-4712-af5e-41aa9eccbdd0 \ No newline at end of file