Added text handling in fetchWithValidation

This commit is contained in:
Aleksandr Kraiz
2022-05-13 21:18:26 +04:00
parent 4fa91465f6
commit a07a91f951
2 changed files with 4 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.5.13",
"version": "0.5.14",
"description": "Orion Protocol SDK",
"main": "./lib/esm/index.js",
"module": "./lib/esm/index.js",

View File

@@ -84,6 +84,9 @@ export default async function fetchWithValidation<DataOut, DataIn, ErrorOut, Err
});
}
const textPayload = schema.safeParse(text);
if (textPayload.success) return ok(textPayload.data);
const safeParseJson = fromThrowable(JSON.parse, (e) => {
if (e instanceof Error) {
return err({