How to solve 'Content-Type error' when i use theme-predictive-search api

JeonghyeonPark
New Member
1 0 0
Hi - I used theme-predictive-search Library as an example shown in the official document, but an error occurs.
here is my code 

 

import PredictiveSearch from '@shopify/theme-predictive-search';

const temp = () => {
  const predictiveSearch = new PredictiveSearch({
    resources: {
      type: [PredictiveSearch.TYPES.PRODUCT],
      limit: 4,
    },
  });

  predictiveSearch.on('success', (json) => {
    console.log('success!', json);
  });

  predictiveSearch.on('error', (error) => {
    console.error('error :', error.message);
  });

  predictiveSearch.query('dark-star');
};

export default temp;

 

I call the temp function from the React component.
and this is error message

 

index.js:1 error : Content-Type error: Content-Type was not provided or is of wrong type
    at new ContentTypeError (http://localhost:3000/static/js/vendors~main.chunk.js:191311:21)
    at XMLHttpRequest.xhr.onreadystatechange (http://localhost:3000/static/js/vendors~main.chunk.js:191032:17)

 

How can i solve it ? plz help
Replies 0 (0)