All my widgets disappear when I use this rule. What am I doing wrong?

My page goes blank, my searchbox and everything vanishes when I add this code to my app.js file.

const rule = {
  objectID: '2652',
  conditions: [{
    pattern: '',
    anchoring: 'is'
  }],
  consequence: {
    hide: {
      objectID: '2652'
    }
  }
};

index.saveRule(rule).then(() => {
  // done
});

The console says ‘index’ is undefined, how do I give it value?