mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
isomorphic-fetch
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Schema, z } from 'zod';
|
||||
import fetch, { FetchError, RequestInit } from 'node-fetch';
|
||||
import fetch from 'isomorphic-unfetch';
|
||||
|
||||
import {
|
||||
err, fromPromise, fromThrowable, ok,
|
||||
} from 'neverthrow';
|
||||
@@ -32,17 +33,10 @@ export default async function fetchWithValidation<DataOut, DataIn, ErrorOut, Err
|
||||
...(options ? options.headers : {}),
|
||||
},
|
||||
}), (e) => {
|
||||
if (e instanceof FetchError) {
|
||||
if (e instanceof Error) {
|
||||
return err({
|
||||
type: 'fetchError' as const,
|
||||
url,
|
||||
message: `${e.message} (${e.type})`,
|
||||
error: e,
|
||||
});
|
||||
} if (e instanceof Error) {
|
||||
return err({
|
||||
type: 'unknownFetchError' as const,
|
||||
url,
|
||||
message: e.message,
|
||||
error: e,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user