Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 958 Bytes

README.md

File metadata and controls

47 lines (34 loc) · 958 Bytes

Autocomplete from api

HTML, CSS, JavaScript

Main goal -> Search + autocomplete data from api and custom html component without frameworks.


Alt Text


A piece of code

  const query = event.target.value;

  const options = {
    method: 'POST',
    mode: 'cors',
    headers: {
      'Content-Type': 'application/json',
      Accept: 'application/json',
      Authorization: 'Token ' + token,
    },
    body: JSON.stringify({ query }),
  };

  fetch(url, options)
    .then((response) => response.json())
    .then((result) => {
      renderResults(result);
      nameInput.focus();
    })
    .catch((error) => console.log('error', error));
};

Download & Installation

git clone https://github.com/cold-world/autocomplete-from-api.git