I'm handling search feature onChange using Axios. It works fine.
But the problem is when the user deletes input to empty. The request still sent.
My code.
    handleSearch = (e) => {
    const query = e.target.value;
    if(this.timeout) clearTimeout(this.timeout);
    this.timeout = setTimeout(() => {
        if (query === '') // do something ????
        requestApi.searchMultiData('search/multi', query)
            .then(response => {
                this.props.data(response.data);
            })
            .catch(error => console.log(error));
    }, 300);
    };
How can I handle that? My solution is when text input empty. The request should be canceled. Any ideas for working with that? Tks.
 
     
    