piece of strapi integration
This commit is contained in:
1 parent
00197d4f9a
commit
91982b8c99
7 files changed
+252
-16
No files matched your search
@@ -36,3 +36,14 @@ export function wrapInitialProps(fn: (ctx: NextPageContext) => void) {
|
||||
export function createApiUrl(path: string) {
|
||||
return `https://api.tmshv.com/hudozka${path}`
|
||||
}
|
||||
|
||||
export function apiGet<I, O>(factory: (response: I) => O) {
|
||||
return async (url: string, defaultResponse: O) => {
|
||||
const res = await requestGet<I>(url, null)
|
||||
if (!res) {
|
||||
return defaultResponse
|
||||
}
|
||||
|
||||
return factory(res)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user