@@ -17,7 +17,7 @@ import {
1717 SubstackItem ,
1818} from "./types" ;
1919
20- const CORS_PROXY = "https://www.whateverorigin.org /get?url=" ;
20+ const CORS_PROXY = "https://lol-origin-84f24d4beb26.herokuapp.com /get?url=" ;
2121const isBrowser = typeof document !== "undefined" ;
2222
2323// Internal API
@@ -29,7 +29,8 @@ const getRawXMLSubstackFeed = async (feedUrl: string) => {
2929 : feedUrl ;
3030 const promise = await fetch ( path ) ;
3131 if ( promise . ok ) return isBrowser ? promise . json ( ) : promise . text ( ) ;
32- } catch ( e ) {
32+ } catch ( error ) {
33+ console . error ( error ) ;
3334 throw new Error ( "Error occurred fetching Feed from Substack" ) ;
3435 }
3536} ;
@@ -56,7 +57,6 @@ const transformRawItem = (item: RawItem): SubstackItem => {
5657
5758export const getSubstackFeed = async (
5859 feedUrl : string ,
59- /* eslint-disable @typescript-eslint/no-explicit-any */
6060 callback ?: ( err : Error | null , result : unknown ) => void ,
6161) : Promise < unknown > => {
6262 const rawXML = await getRawXMLSubstackFeed ( feedUrl ) ;
@@ -78,8 +78,10 @@ export const getFeedByLink = (
7878 return rawFeed . rss . channel
7979 . filter ( isRawFeedChannel )
8080 . filter ( ( channel ) => channel . link [ 0 ] === link ) ;
81- } catch ( e ) {
82- throw new Error ( `Error occurred fetching Feed by Link: ${ link } ` ) ;
81+ } catch ( e : unknown ) {
82+ const error = new Error ( `Error occurred fetching Feed by Link: ${ link } ` ) ;
83+ ( error as any ) . cause = e ;
84+ throw error ;
8385 }
8486} ;
8587export const getPosts = ( channels : RawFeedChannel [ ] ) => {
@@ -108,15 +110,15 @@ const getRawXMLGoodreadsFeed = async (feedUrl: string, proxy?: string) => {
108110 : feedUrl ;
109111 const promise = await fetch ( path ) ;
110112 if ( promise . ok ) return isBrowser ? promise . json ( ) : promise . text ( ) ;
111- } catch ( e ) {
113+ } catch ( error ) {
114+ console . error ( error ) ;
112115 throw new Error ( "Error occurred fetching Feed from Goodreads" ) ;
113116 }
114117} ;
115118
116119// Public API
117120export const getGoodreadsFeed = async (
118121 feedUrl : string ,
119- /* eslint-disable @typescript-eslint/no-explicit-any */
120122 callback ?: ( err : Error | null , result : unknown ) => void ,
121123 proxy ?: string ,
122124) : Promise < unknown > => {
0 commit comments