Getting Error : setting warmup data is not supported in the browser

Hi ,
may i know why am getting this Error

setting warmup data is not supported in the browser

Hi,

You can only set warmupData in the backend. If you want to get rid of the error, you can wrap the setting with

if (wixWindow.rendering.env == "backend") 

as it’s shown in the code example here: https://www.wix.com/velo/reference/wix-window/warmupdata-obj/set

For more information, check out the post about this API here: https://www.wix.com/velo/forum/news-announcements/new-and-improved-warmup-data-api

Hi,
Thanks so much.
Now Am facing New Problem

And Please Support me with this Issue Too

FYI, for the warmupData stuff…either the docs are wrong, or the API is broken. The docs show the following example:

(note line 8 in bold)

async function getData() {
5  const results = await wixData.query("MyCollection")
6    .find();
7  if (wixWindow.rendering.env == "backend") {
8    wixWindow.warmupData.set("myWarmupData", results.items);
9    wixWindow.warmupData.set("myWarmupMessage", "Rendering in the backend.");
10  }
11  return results;
12}

This code does not compile. Apparently, the set method takes two strings as parameters. (string key, string data). result.items is not a string, so I get the red squiggly with the message:

Argument of type ‘any[]’ is not assignable to parameter of type ‘string’.

I’m guessing you have to JSON.stringify the set and then JSON.parse the get. But it would be great if either the docs or the API could be fixed.

Thanks

how did you solved this issue
I’m also facing the same warning