Handle case where params.fuseOpts is not defined

resulting into `Cannot read properties of null (reading 'limit')`
This commit is contained in:
Aditya Telange 2023-08-12 13:14:35 +05:30
parent e71444b776
commit d609e5d29b
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77

View File

@ -77,7 +77,12 @@ sInput.onkeyup = function (e) {
// run a search query (for "term") every time a letter is typed // run a search query (for "term") every time a letter is typed
// in the search box // in the search box
if (fuse) { if (fuse) {
const results = fuse.search(this.value.trim(), {limit: params.fuseOpts.limit}); // the actual query being run using fuse.js let results;
if (params.fuseOpts) {
results = fuse.search(this.value.trim(), {limit: params.fuseOpts.limit}); // the actual query being run using fuse.js along with options
} else {
results = fuse.search(this.value.trim()); // the actual query being run using fuse.js
}
if (results.length !== 0) { if (results.length !== 0) {
// build our html if result exists // build our html if result exists
let resultSet = ''; // our results bucket let resultSet = ''; // our results bucket