-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data-access): add get haqq whitepaper method
- Loading branch information
1 parent
37ff893
commit 4d92ebc
Showing
3 changed files
with
36 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
import { cache } from 'react'; | ||
import { getIslamicWhitepaperData } from '@haqq/data-access-falconer'; | ||
import { getHaqqWhitepaperData } from '@haqq/data-access-falconer'; | ||
import { REVALIDATE_TIME } from '../constants'; | ||
|
||
export const revalidate = REVALIDATE_TIME; | ||
|
||
export const getWhitepaperContentFromFalconer = cache( | ||
async (locale?: string) => { | ||
try { | ||
const data = await getIslamicWhitepaperData( | ||
{ | ||
next: { | ||
revalidate, | ||
}, | ||
}, | ||
locale ?? 'en', | ||
); | ||
export const getWhitepaperContentFromFalconer = cache(async () => { | ||
try { | ||
const data = await getHaqqWhitepaperData({ | ||
next: { | ||
revalidate, | ||
}, | ||
}); | ||
|
||
return data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
return data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
|
||
return ''; | ||
}, | ||
); | ||
return ''; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
libs/data-access/falconer/src/lib/haqq/get-haqq-whitepaper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { FALCONER_ENDPOINT } from '../../constants'; | ||
import { FalconerRequestInit } from '../../types'; | ||
|
||
export async function getHaqqWhitepaperData( | ||
options: Partial<FalconerRequestInit>, | ||
) { | ||
const requestUrl = new URL('/haqq/wp', FALCONER_ENDPOINT); | ||
|
||
const response = await fetch(requestUrl, { | ||
method: 'GET', | ||
...options, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Whitepaper fetch failed'); | ||
} | ||
|
||
const responseJson = await response.json(); | ||
|
||
return responseJson.wp as string; | ||
} |