I get this error when using Wix.Utils.getInstanceId(): cannot read property ‘substring’ of null

Your component is redirecting to another endpoint without passing all the provided query parameters (required by our JS SDK).

If you need to use URL redirect, here’s how to do it (note that we don’t recommend using URL redirect, because it can cause errors):

  1. Include a reference to our Javascript SDK in the target endpoint’s HTML document.
  2. Pass all query parameters to the target endpoint (see the required query parameters for widget, page, and dashboard components).
    If your URL contains a hashbang (#!), insert the query parameters before it.

NodeJS Example:
function getQueryString(q) {
   var query = "?";
   _.each(q, function(value, key){
       query += (key + "=" + encodeURIComponent(value) + "&");
   });
   return query.substring(0, query.length - 1);
}

exports.appRedirect = function(req, res){
       var query = getQueryString(req.query);
       // Make sure to pass Wix’s parameters before the Hashbang
       res.redirect(query + '#/myRoute/myParams'); 
};


Related Content