【问题标题】:Nativescript multiple fetch http postNativescript 多次获取 http 帖子
【发布时间】:2016-07-11 12:52:00
【问题描述】:

我遇到了一个小问题。我应该如何进行循环 POST(数据数组),我需要一个一个发送,但在发送另一个之前等待较早的 POST 响应。欢迎任何想法!

我正在使用最新的 Nativescript 和股票获取模块。

【问题讨论】:

    标签: arrays loops http fetch nativescript


    【解决方案1】:

    听起来像是对我的递归调用,例如:

    function postData(arr, index){
    
    let itemToPost = arr[index];
    
    fetch('https://xyz/some/url', {
        method: 'post'
        content: json.stringify(itemToPost)// something like this
    
    
    }).then(function(response) { //success
    
        //recursive call here 
        postData(arr, ++index)
    
    }).catch(function(err) {
        // Error :(
    });
    }
    

    【讨论】:

    • 我试试看!
    猜你喜欢
    • 1970-01-01
    • 2018-11-24
    • 1970-01-01
    • 2021-05-19
    • 2013-12-10
    • 1970-01-01
    • 2014-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多