如何仅停止最后一个提取请求

时间:2018-12-12 14:49:58

标签: javascript vue.js fetch

所以我试图从网站上获取一些照片以创建画廊。 问题是当我想按作者排序时,我清空我的照片[]以在提取中重新填充照片。

sortByAuthor() {
    console.log('Sort')
    this.setPhotos([]); //Emptying
    this.fetchGallery();
},
fetchGallery() {
    const url = new URL('wtv');
    const params = {
        author: this.sortByAuthor ? this.sortByAuthor : '',
        order: this.sortByDate,
        limit: this.limit
    };
    url.search = new URLSearchParams(params);

    fetch( url , {
        method: 'GET',
    }).then((response) => {

        response.json().then((data) => {
            this.fetchGallery(this.photos.length)
        });
    }).catch();
}

enter image description here

您将如何仅取消上一个感染?

0 个答案:

没有答案