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

@@ -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({