<commit_before>var when = require('./lib/when');
var Components = require('./collections/components');
var ListView = require('./views/list');
var ComponentView = require('./views/component');

module.exports = Backbone.Router.extend({

  routes: {
    '': 'home',
    'search/:query': 'query',
    'components/:owner/:module': 'component'
  },

  initialize: function () {
    var router = this;
    var deferred = when.defer();
    this.initialized = deferred.promise;
    this.components = new Components();

    this.components.fetch({
      success: deferred.resolve,
      error: deferred.reject
    });
  },

  clearView: function () {
    if (this.view && this.view.destroy) {
      this.view.destroy();
    }
  },

  setView: function (view) {
    this.clearView();
    this.initialized.then(function () {<commit_msg>Add an error debugging when cannot pull from API<commit_after>var when = require('./lib/when');
var Components = require('./collections/components');
var ListView = require('./views/list');
var ComponentView = require('./views/component');

module.exports = Backbone.Router.extend({

  routes: {
    '': 'home',
    'search/:query': 'query',
    'components/:owner/:module': 'component'
  },

  initialize: function () {
    var router = this;
    var deferred = when.defer();
    this.initialized = deferred.promise;
    this.components = new Components();

    this.components.fetch({
      success: deferred.resolve,
      error: deferred.reject
    });

    this.initialized.then(null, function (err) {
      console.error('Could not fetch components');
    });
  },

  clearView: function () {
    if (this.view && this.view.destroy) {
      this.view.destroy();
    }
  },

  setView: function (view) {
    this.clearView();
    this.initialized.then(function () {
{'fraction_non_alphanumeric': 0.16481069042316257, 'fraction_numerical': 0.0, 'mean_word_length': 3.1790697674418604, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4285421', 'n_tokens_mistral': 536, 'n_tokens_neox': 528, 'n_words': 114}