Thursday 20 April 2017

Fuse.js constructor issue

Im trying to add a fuzzy search library to my project via fuse.js. I include the following lines and I'm getting a constructor error, I tried to re-install fuse but I'm wondering where the error may be.

//TypeError: Fuse is not a constructor





var Fuse = require('fuse');



var options = { // list of options that need to be provided to fuse.js for search to occur
  shouldSort: true,
  threshold: 0.6,
  location: 0,
  distance: 100,
  maxPatternLength: 32,
  minMatchCharLength: 1,
  keys: [
    "title", // the keys that are searched
    "decription"
]
};

var fuse = new Fuse(posts, options); // "list" is the item array
var result = fuse.search(searchOptions.keywords); // search is conducted and result should be all matching json objects



via learner561

No comments:

Post a Comment