get( )


Gets data from server-side code for use in client-side code.

A performance best practice is to get warmup data on the server for time-consuming operations, such as querying collections or working with the results of network requests from external sites. You can write code that sets the data from these operations as warmup data on the server. The client-side code can then get that data without performing the operations again.

Getting the warmup data retrieves data that was set on the server and makes the data accessible from the client-side.

You can only get warmup data in the client-side code.

  • This function returns null if called while on the server.
  • If this function runs before warmupData.set(), it returns undefined.

Notes:

  • Rendering never occurs server-side when previewing a site.
  • Server-side rendering only occurs when visitors initially enter a site, and not when visitors navigate from page-to-page within a site.
Method Declaration
Copy
Method Parameters
keystringRequired

Name representing the data to return to the client-side. Until rendered, the data is undefined.

Returns
Return Type:Promise<any>
Did this help?