when upgrading from v3.4.6 to v6.0.0, my javascript code breaks
TypeError: Cannot read property 'map' of undefined
I've tracked down that the fuse.search() is returning undefined after upgrading, when before the upgrade.
import Fuse from 'fuse.js'
export default function filterRecipeList(searchValue, recipesToSearch) {
var options = {
shouldSort: true,
tokenize: true,
threshold: 0.3,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: ['id', 'name', 'ingredients.name']
}
console.log(recipesToSearch)
console.log('handleRecipeSearch options: ' + options)
var fuse = new Fuse(recipesToSearch, options) // "list" is the item array
console.log('handleRecipeSearch searchValue: ' + searchValue)
var result = fuse.search(searchValue)
console.log('handleRecipeSearch result: ' + result)
return result
}
Any Ideas? Does it have anything to do with my node.js version?
What does recipesToSearch look like?
Any Ideas? Does it have anything to do with my node.js version?
I do not know what your node version is 😄
node
recipesToSearch
[
{
id: 1,
name: 'Plain Chicken',
servings: 3,
cookTime: '1:45',
instructions: "1. Put salt on chicken\n2. Put chicken in oven\n3. Eat chicken",
ingredients: [
{
id: 1,
name: 'Chicken',
amount: '2 Pounds'
},
{
id: 2,
name: 'Salt',
amount: '1 Tbs'
}
]
},
{
id: 2,
name: 'Plain Pork',
servings: 5,
cookTime: '0:45',
instructions: "1. Put paprika on pork\n2. Put pork in oven\n3. Eat pork",
ingredients: [
{
id: 1,
name: 'Pork',
amount: '3 Pounds'
},
{
id: 2,
name: 'Paprika',
amount: '2 Tbs'
}
]
}
]
Mine broke too. Something to do with tokenize?
Nope, that's not it. Still trying to figure out why it's broken. I didn't see any breaking changes announced in the changelogs, so I'm not yet sure where to look.
Okay, I figured it out. The search results are now wrapping each item in an object under key item. So to get it to work as before you need to do something like `results = results.map(i => i.item);
This is actually mentioned in the changelog, without saying what was actually changed about the search results. The trick here is apparently this library doesn't show breaking changes in major version updates, but in each of the beta updates, so you need to read through all of the many beta updates to pick up on breaking changes.
Yep! I found the itemized returned results just yesterday, haven’t updated my code yet
On 6 Jun 2020, at 08:38, jazoom notifications@github.com wrote:

Okay, I figured it out. The search results are now wrapping each item in an object under key item. So to get it to work as before you need to do something like `results = results.map(i => i.item);
This is actually mentioned in the changelog, without saying what was actually changed about the search results. The trick here is apparently this library doesn't show breaking changes in major version udates, but in each of the beta updates, so you need to read through all of the many beta updates to pick up on breaking changes.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/krisk/Fuse/issues/428#issuecomment-639946438, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AE6BZABBU2GJE2YXUKAYUXLRVGMYJANCNFSM4NRF7LVQ.
[EDIT]
For those searching for the same question, it seems that the extended search option is here to replace this option and offer new possibilities to customise search.
(If it's OK, i'll just let my issue here, for those who search for the same response)
Hi, I've been using fuse in the past (with a older version and documentation) and today I'm using the current, version, but it seems the "tokenize" parameter is no where to be found in the new documentation. Is this option has been removed ? If so, why and how could we replace its behaviour.
Thanks.
Yes. This is my bad. I failed to update the changelog. Will be more disciplined moving forward.
Most helpful comment
Okay, I figured it out. The search results are now wrapping each item in an object under key
item. So to get it to work as before you need to do something like `results = results.map(i => i.item);This is actually mentioned in the changelog, without saying what was actually changed about the search results. The trick here is apparently this library doesn't show breaking changes in major version updates, but in each of the beta updates, so you need to read through all of the many beta updates to pick up on breaking changes.