react-storefront
react-storefront copied to clipboard
Search does not work (possible routing/API issue).
Bug report
Describe the bug
On localhost:3000
or http://localhost:3000/s/1
typing anything in the search bar leads to
Unhandled Runtime Error
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
at http://localhost:3000/search?q=a
or if the search query contains spaces, like on http://localhost:3000/search?q=a%201
we see:
Server Error
FetchError: invalid json response body at http://localhost:3000/api/search?q=a%201&_includeAppData=1 reason: Unexpected token I in JSON at position 0
This error happened while generating the page. Any console logs will be displayed in the terminal window.
at pages/_app.js (54:16) @ async Function.MyApp.getInitialProps
To Reproduce
Steps to reproduce the behavior:
- just follow steps at
https://docs.reactstorefront.io/guides/getting_started
for version 8.18.3 - Open the localhost in the browser and try searching
a
ora 1
Expected behavior
The search results page should be displayed even if no hits were found.
System information
- OS: Kubuntu 20.04
- Browser firefox esr
- Version of React Storefront: [e.g. 8.18.3]
I tried an earlier version also, I guess the [...subCategory].js API is getting mangled with search API? IDK..
I think the issue is in this line https://github.com/storefront-foundation/react-storefront/blob/489f632aa588b8286e1c621771c5f11e91b07d7f/src/mock-connector/subcategory.js#L12, the filters on param probably is not null at all but it's not a valid json
+1