月饼与我无缘
function wait(time) {
return new Promise(ok => {
setTimeout(() => {
ok()
}, time || 2000);
})
}
async function getData() {
const url = `
api.juejin.cn`;
const stream = await fetch(url, {
method: "POST",
credentials: "include",
body: JSON.stringify({})
});
const res = await stream.json();
await wait(2000 + Math.random() * 2000);
return res;
}
const map = {};
while (true) {
const res = await getData();
map[res.data.lottery_name] = map[res.data.lottery_name] ? map[res.data.lottery_name] + 1 : 1;
console.log(JSON.stringify(map));
}
function wait(time) {
return new Promise(ok => {
setTimeout(() => {
ok()
}, time || 2000);
})
}
async function getData() {
const url = `
const stream = await fetch(url, {
method: "POST",
credentials: "include",
body: JSON.stringify({})
});
const res = await stream.json();
await wait(2000 + Math.random() * 2000);
return res;
}
const map = {};
while (true) {
const res = await getData();
map[res.data.lottery_name] = map[res.data.lottery_name] ? map[res.data.lottery_name] + 1 : 1;
console.log(JSON.stringify(map));
}
展开
评论
点赞