From 76f8631e33ece7072debf889579ef444b3c15aee Mon Sep 17 00:00:00 2001 From: Vojtech Simetka Date: Thu, 20 May 2021 17:24:24 +0200 Subject: [PATCH 1/2] fix: if there are no postage stamps the getAllPostageBatch returns null --- src/bee.ts | 2 +- src/modules/stamps.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bee.ts b/src/bee.ts index e99f7c89..8dd32a80 100644 --- a/src/bee.ts +++ b/src/bee.ts @@ -605,7 +605,7 @@ export class Bee { /** * Return all postage batches that has the node available. */ - getAllPostageBatch(): Promise { + getAllPostageBatch(): Promise { return stamps.getAllPostageBatches(this.url) } diff --git a/src/modules/stamps.ts b/src/modules/stamps.ts index 92d84a65..d3dbd4b4 100644 --- a/src/modules/stamps.ts +++ b/src/modules/stamps.ts @@ -13,7 +13,7 @@ interface CreateStampResponse { batchID: Address } -export async function getAllPostageBatches(url: string): Promise { +export async function getAllPostageBatches(url: string): Promise { const response = await safeAxios({ method: 'get', url: `${url}${STAMPS_ENDPOINT}`, From c7a15e3f9b5b0cd50641081dd5c62b322ec2a2bd Mon Sep 17 00:00:00 2001 From: Vojtech Simetka Date: Thu, 20 May 2021 17:28:00 +0200 Subject: [PATCH 2/2] chore: it should just return empty array --- src/bee.ts | 2 +- src/modules/stamps.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bee.ts b/src/bee.ts index 8dd32a80..e99f7c89 100644 --- a/src/bee.ts +++ b/src/bee.ts @@ -605,7 +605,7 @@ export class Bee { /** * Return all postage batches that has the node available. */ - getAllPostageBatch(): Promise { + getAllPostageBatch(): Promise { return stamps.getAllPostageBatches(this.url) } diff --git a/src/modules/stamps.ts b/src/modules/stamps.ts index d3dbd4b4..558a380f 100644 --- a/src/modules/stamps.ts +++ b/src/modules/stamps.ts @@ -13,14 +13,14 @@ interface CreateStampResponse { batchID: Address } -export async function getAllPostageBatches(url: string): Promise { +export async function getAllPostageBatches(url: string): Promise { const response = await safeAxios({ method: 'get', url: `${url}${STAMPS_ENDPOINT}`, responseType: 'json', }) - return response.data.stamps + return response.data.stamps || [] } export async function getPostageBatch(url: string, postageBatchId: Address): Promise {