Semantic UI Search Error 503

Response successful when you try to paste or click the input after typing:

I’m getting this error Semantic UI search module. If I try in my browser this endpoint: https://observant-handsomely-vanadium.glitch.me/api/products/search?q=A52

it works. however if I set it at Semantic ui’s search api it returns error 503 on press of two letters? I tried also adding searchDelay and implemented cors in server.js but still error 503 persist.

I’'m using hello express app, and here is the code in my script.js:

$.fn.api.settings.api = {
  'search': '/api/products/search?q={query}'
};
$(".ui.search").search({
  // change search endpoint to a custom endpoint by manipulating apiSettings
  type          : 'category',
  minCharacters : 1, // just under devel to make it easy
  apiSettings   : {
    action: 'search'
  },searchDelay: 200,
  //searchFields: ["title"]
});

while this is my code at server.js:

// search products
app.get("/api/products/search", (request, response) => {
  try {
    axios
      .get(productsUrlSearch.replace("%q",request.param("q")))
      .then(responseProducts => {
        response.json(responseProducts.data);
      })
      .catch(error => {
        console.log(error);
      });
  } catch (err) {
    console.error("GG", err);
  }
});

I hope to get help from this :frowning: else I will just try keyup function with jQuery instead.

Can you show us your logs?

Fix: request.query.q not request.param("q")

2 Likes

here is the logs with error. I can’t capture them with semantic ui search logs because it throws error and clears the logs on console.

This works. I saw the deprecate error. however the error still persist, it seems to be only applicable on Google Chrome? Something on request being cancelled. although I already added CORS()

this is the logs of semantic UI when I just outright copy paste a value in it. But If I start typing in two characters it throws error 503 but refer to the picture I posted initially. It cancels the request for the reason i don’t know yet

I think you were referring to glitch console log? this is the error. Socket hang up.

it throws when I typed more than 1 character

I think it’s already goood! I just re-added cors and implemented what @Yonle suggested. Thanks! :slight_smile:

1 Like