piece of strapi integration

This commit is contained in:
tmshv committed 2021-02-13 19:01:34 +03:00
1 parent 00197d4f9a
commit 91982b8c99
7 files changed
+252 -16

No files matched your search

+11
View File
@@ -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)
}
}