Sobes.tech
Junior — Senior

Debounced API request on input

livecode

Task condition

Task – to simulate a text search where the server request is made only after a pause in typing. Requirements:

  • Handle each change in the string, but call the request-sending function only if the user has not entered new characters for 1 second.
  • Use plain JavaScript, without third-party libraries and frameworks.
  • It is not necessary to create an HTML form – just implement a reaction to a conditional call onChange(value).
  • React environment cannot be used.
/*
  const fetchData = (value: string) => console.log(value)
*/