I have an array like this: json data
I'm trying to pass this variable into fetch request. I've try using JSON.stringify(data) but it return an empty array []
how can I fix this
This is my code so far:
const getCookies = (param) =>
new Promise((resolve, reject) => {
chrome.cookies.getAll(param, (cookies) => {
resolve(cookies)
});
});
chrome.storage.sync.get(["isGet"], (item) => {
try {
var list = new Array();
for (let i = 0; i < url.length; i++) {
const param = {
url: url[i],
};
getCookies(param).then((item) => {
list[i] = item
});
}
console.log(list);
console.log(JSON.stringify(list))
sendReq(list).then(() => {
chrome.storage.sync.set({ isGet: true });
});
} catch (error) {
chrome.storage.sync.set({ isGet: false });
console.log(error);
}
});