当我使用按符号搜索时,我遇到问题,为什么要通过任何符号发送请求?

时间:2019-03-13 04:21:19

标签: javascript reactjs

searchEmployee(e) {
    const {entityType} = this.state;
    const searchText = this.searchInput.value;

    if (e.target.value !== '' && searchText.length !== 0) {
        this.drop.hide();

        if (searchText.length > 3) {
            this.timeout = setTimeout(() => {
                this.setState({
                    showSearchLoader: true,
                    result: [],
                    resultCounts: [],
                    hasMoreItems: false,
                    searchResultsEmpty: false,
                    entityType: 10,
                    searchAll: true
                });

                this.getResults(searchText, entityType, this.searchResultsCount, 0, false);
            }, 1000);
        }
    }

}

getResults(searchText, entityType, searchResultsCount, offset, concat = true) {
    const {result: stateResult} = this.state;

    searchGlobal(searchText, entityType, searchResultsCount, offset).then(({result, resultCounts}) => {
        this.setState({
            result: concat ? _.concat(stateResult, result) : result,
            resultCounts,
            offset: offset,
            hasMoreItems: result.length >= 8,
            showSearchLoader: false,
            searchResultsEmpty: !result.length
        });

        this.searchInput.focus();
        setTimeout(() => this.drop.show(), 400);
    }).catch(handleErrorResponse);
}

get request
当我在超时时间内打印两个或多个符号时,我将收到两个或多个请求! 而这个请求又回到我这里了!
事实证明,从另一个化身返回数据的人,如何提出这样的要求,即他不发送每个字符,而只发送最后要打印的字符

0 个答案:

没有答案