diff --git a/README.md b/README.md index fb760ce..c3f70d1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# tokensoft-sdk +# @tokensoft/sdk ![Logo](./docs/img/logo.png) @@ -69,3 +69,7 @@ const transactionHash = await client.authorizeUser('jay_clayton@gmail.com', '0x0 * Added `recordPayment` function which can be used to call the `externalRecordPayment` endpoint +### 1.1.0 -> 1.1.1 + +* Refactored `recordPayment` to return an error if there is one + diff --git a/src/index.ts b/src/index.ts index b57fb27..12fe86a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -211,6 +211,21 @@ export class TokensoftSDK { }` }) - return this.sendRequest(body).then(d => d?.data) + const res = await this.sendRequest(body) + + if ( + (!res.data || Object.values(res.data).find(v => v === null) !== undefined) && + res.errors && + res.errors.length + ) { + throw new Error( + res.errors + // @ts-ignore + .map(e => e.message) + .join('; ') + ) + } + + return res.data } }