mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-17 08:41:38 +03:00
Fix fetching
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.5.17",
|
||||
"version": "0.5.18",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/esm/index.js",
|
||||
"module": "./lib/esm/index.js",
|
||||
|
||||
@@ -84,9 +84,6 @@ 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({
|
||||
@@ -106,7 +103,11 @@ export default async function fetchWithValidation<DataOut, DataIn, ErrorOut, Err
|
||||
|
||||
const jsonResult = safeParseJson(text);
|
||||
|
||||
if (jsonResult.isErr()) return jsonResult.error;
|
||||
if (jsonResult.isErr()) {
|
||||
const textPayload = schema.safeParse(text);
|
||||
if (textPayload.success) return ok(textPayload.data);
|
||||
return jsonResult.error;
|
||||
}
|
||||
|
||||
const json: unknown = jsonResult.value;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user