如何使用axios处理大量请求?

vlf7wbxs  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(255)

我在sqlite中有一个数据库,其中有几个表,大约有82000条记录,但我需要将它们发送到一个api,我使用sqlite模块来读取它,到目前为止还不错,当我尝试使用axios管理和发送所有这些记录时,问题来了,他感到头晕,最后给我一个内存错误,显然,这是一个承诺,但我是新的,我不处理自己很好,我留给你一段代码,我在其中执行的操作。

function sendrow(tablas) {

tablas.forEach(element => {

    axios.post('http://xx.xx.xx.xxx:1337/categories', {
        id:element.id,
        title:element.title,
        sort:element.sort,
        pubdate:element.pubdate,
        author_sort:element.author_sort,
        path:element.path
    })
        .then(function (response) {
            console.log(response);
        })
        .catch(function (error) {
            console.log(error);
        });
});

}名为“tabla”的函数param包含大约82000条记录,如果我将其限制在200条以下,则效果良好。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题