const fetchData = async (e) => {
const arr = []
const newres = await axios.get(`https://api.aftership.com/v4/trackings/?tag=${tag}&created_at_min=${minCreate}&created_at_max=${maxCreate}&page=${page}&limit=200`, {
headers: {
"Content-Type": "application/json",
"aftership-api-key": `${apiKey}`
},
/* responseType: "blob" */
})
const res = await newres.data.data.trackings
arr.push(newres.data.data.trackings)
const pageNumber = newres.data.data.count/200;
const exactPage = Math.ceil(pageNumber);
for(let i=1; i<=exactPage; i++) {
let newarr = []
let n = await axios.get(`https://api.aftership.com/v4/trackings/?tag=${tag}&created_at_min=${minCreate}&created_at_max=${maxCreate}&page=${i}&limit=200`, {
headers: {
"Content-Type": "application/json",
"aftership-api-key": `${apiKey}`
},
})
const arrr = n.data.data.trackings
res.concat(arrr)
console.log(i);
}
我试图合并所有的数组到1个对象,我们可以下载到CSV,但所有的数组来分开。有人能帮助吗?
1条答案
按热度按时间oug3syen1#
这是一个如何合并数组的例子:
我认为您需要在代码中更改:
致:
型
并将res从const更改为let
注意:concat()方法用于合并数组。