react-storefront icon indicating copy to clipboard operation
react-storefront copied to clipboard

Search does not work (possible routing/API issue).

Open s-c-p opened this issue 3 years ago • 3 comments

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:

  1. just follow steps at https://docs.reactstorefront.io/guides/getting_started for version 8.18.3
  2. Open the localhost in the browser and try searching a or a 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]

s-c-p avatar Sep 30 '21 11:09 s-c-p

I tried an earlier version also, I guess the [...subCategory].js API is getting mangled with search API? IDK..

s-c-p avatar Sep 30 '21 11:09 s-c-p

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

ahmad-reza619 avatar Oct 19 '21 13:10 ahmad-reza619

+1

ScyDev avatar Dec 08 '21 15:12 ScyDev