我需要向服务器发送一些数据,以更改正在提供的活动“义务”。
在对网站进行任何操作之前,我需要等待主动承担的义务发生变化。
但是,我不需要获取获取的响应。我想等到数据发送完毕,而不必等到收到响应。
async function scrape(obligations) {
array = []
for (obligation in obligations) {
data = await switchObligations(obligations[obligation]).then(async function() {
let obj = {}
const promises = config.filter(function(page){
if (page.active === true && page.name !== 'debtorAddress') {
return true;
}
return false;
}).map(async (page) => {
let data;
htmlText = await getPage(page)
if(page.type !== 'table') {data = await parsePage(page, htmlText);}
else {let table = getTable(htmlText, undefined, page)
}
return data;
})
data = Promise.all(promises).then(dataArray => {
let data = Object.assign({}, ...dataArray)
array.push(data);
return array;
})
return await data
});
}
return await data
}
async function switchObligations(obligation){
//Changes the active obligation
const res = fetch("https://djr.view.civicacloud.com.au/Traffic/Notices/forms/NoticesManagement/SearchNotice.aspx?&NoticeNo=" + obligation, {
method: 'GET',
});
return res
}
答案 0 :(得分:1)
在评论中进行了大量讨论之后,要求是不遵循switchObligations
函数中从URL返回的重定向响应
这是通过使用redirect:
的{{1}}参数的init
属性来实现的
即在代码中
fetch
添加重定向:属性如下
fetch("https://***url***", {
method: 'GET',
})