From ec614ab355db980df7beceb45b5b4d87c56a0927 Mon Sep 17 00:00:00 2001 From: theocod3s Date: Mon, 29 Apr 2024 12:09:04 +0100 Subject: [PATCH] add error handling to readme --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e35d37c..d84a2bd 100644 --- a/README.md +++ b/README.md @@ -22,18 +22,33 @@ Here's how to configure the SDK: ```typescript const genesiscloud = new GenesisCloudClient({ - TOKEN: "your_api_token_here", + TOKEN: process.env.GENESISCLOUD_TOKEN, }); ``` ## Examples +### Error handling + +Error handling can be done using the try/catch with the async/await syntax. For example: + +```typescript +const listImages = async () => { + try { + const { images } = await genesiscloud.images.listImages({}); + return images; + } catch (error) { + // ... handle the error + } +}; +``` + ### Managing Instances Listing Instances: ```typescript -const instances = await genesiscloud.instances.listInstances({ +const { instances } = await genesiscloud.instances.listInstances({ page: 1, perPage: 100, });