Use the logging utility from the JS SDK
Search JS SDK for React offers a logging utility that you can use during development. You can monitor data requests and responses, and also watch values while debugging in development.
To use the logging utility to print everything and debug:
-
In the root of your application, to instantiate the logging utility, outside the
WidgetsProviderwrapper, paste the following code block:RequestResponseimport { Logger } from 'sitecore-search/react'; Logger.setLogLevel(Logger.DEBUG);TipUse an environment variable as the value for the
Loggerlevel and to prevent tracing in production, set it toLogger.NONEfor production.The
setLogLevelfunction accepts enum values.