fetchPage
The fetchPage function is useful when you want to retrieve the content of one page from outside the React context (where you could use the usePagePublic hook instead).
In particular, this comes in handy during the build process of a static website. Indeed, this is the method used in our Gatsby and Next.js starter projects.
Signature
Property | Definition |
---|---|
pageSlug | The slug (string) of the page to fetch. |
apiKey | Api Key of your React Bricks app (a string). |
language? | The language of the desired translation for the page, if more than one share the same slug |
pageTypes? | The pageTypes used in React Bricks configuration. Useful only if you have external content (fetchPage cannot access them from the React context). |
Return value
fetchPage
returns a promise which resolves to a Page
Before using this page with ReactBricks’ PageViewer
component, you need to parse it with the cleanPage
function.