travis-r6s / gridsome-plugin-flexsearch

Add lightning fast search to Gridsome with FlexSearch
24 stars 7 forks source link

Error when manually fetching flexsearch.json after upgrading to version 1.0.1 #46

Closed chrispreisler closed 4 years ago

chrispreisler commented 4 years ago

Hey @thetre97,

I am manually fetching the flexsearch.json, how you recommended to me in #37

After upgrading to the newest version unfortunately I get the following error:

Bildschirmfoto 2020-06-30 um 17 03 11

When setting autoFetch to true the search is working as expected. Do I have to change anything in the new version to manually load the flexsearch.json?

async mounted() {
    const searchIndex = await fetch(`/flexsearch.json`)
      .then(r => r.json())
      .then(j => cjson.decompress(j));
    this.$search.import(searchIndex, { serialize: false });
  },

Gridsome is also upgraded to the newest version. (0.7.17)

Thank you very much for your help.

Best regards Chris

travis-r6s commented 4 years ago

You can check the latest updates in this file: https://github.com/thetre97/gridsome-plugin-flexsearch/blob/508f8dd8ec53ec8d0473f746671952aa2df87299/gridsome.client.js#L13 The issue is probably because I changed the default compress option to false, so unless you specifically set that to true, you don't need to do cjson.decompress(j) anymore.

chrispreisler commented 4 years ago

Ah I see, thank you very much. Now it is working.