【发布时间】:2016-07-11 12:52:00
【问题描述】:
我遇到了一个小问题。我应该如何进行循环 POST(数据数组),我需要一个一个发送,但在发送另一个之前等待较早的 POST 响应。欢迎任何想法!
我正在使用最新的 Nativescript 和股票获取模块。
【问题讨论】:
标签: arrays loops http fetch nativescript
我遇到了一个小问题。我应该如何进行循环 POST(数据数组),我需要一个一个发送,但在发送另一个之前等待较早的 POST 响应。欢迎任何想法!
我正在使用最新的 Nativescript 和股票获取模块。
【问题讨论】:
标签: arrays loops http fetch nativescript
听起来像是对我的递归调用,例如:
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 :(
});
}
【讨论】: