added wrapper to getInitialProps to prevent api calls in production
This commit is contained in:
1 parent
dded475c47
commit
fe5cc36182
12 files changed
+49
-33
No files matched your search
+3
-3
@@ -8,7 +8,7 @@ import menuModel from '../src/models/menu'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
import { splitBy } from '../src/lib/array'
|
||||
import { meta } from '../src/lib/meta'
|
||||
import { createApiUrl, requestGet } from '../src/next-lib'
|
||||
import { createApiUrl, requestGet, wrapInitialProps } from '../src/next-lib'
|
||||
|
||||
const albumsByYear = splitBy(album => new Date(album.date).getFullYear())
|
||||
|
||||
@@ -81,7 +81,7 @@ const Page = (props) => (
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const res = await requestGet(createApiUrl(ctx.req, `/api/albums`), {})
|
||||
const items = res.items || []
|
||||
@@ -97,6 +97,6 @@ Page.getInitialProps = async (ctx) => {
|
||||
description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default Page
|
||||
Reference in new issue
Block a user