UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
at C:\Users\Misha\Desktop\slaves\test2.js:23:18
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Timeout.buyFetter [as _onTimeout] (C:\Users\Misha\Desktop\slaves\test2.js:16:5)
(Use `node --trace-warnings ...` to show where the warning was created)
async function buyFetter() {
await fetch("https://pixel.w84.vkforms.ru/HappySanta/slaves/1.0.0/start", {
method: "GET",
headers: {
"Content-Type": "application/json",
authorization: config.authorization
}
}).then(a => a.json()).then(a => {
a.slaves.map(async b => {
if (0 === b.fetter_to) await axios.post("https://pixel.w84.vkforms.ru/HappySanta/slaves/1.0.0/buyFetter", {
slave_id: b.id
}, {
headers: {
authorization: config.authorization
}
}), vk.api.messages.send({
peer_id: config.vk.chat,
random_id: 0,
message: `Купил оковы для @id$ {
b.id
}`
});
else if ("" === b.job.name) {
let c = utils.pick(["утка", "@ut1ka"]);
await axios.post("https://pixel.w84.vkforms.ru/HappySanta/slaves/1.0.0/jobSlave", {
slave_id: b.id,
name: c
}, {
headers: {
authorization: config.authorization
}
}), vk.api.messages.send({
peer_id: config.vk.chat,
random_id: 0,
message: `Установил работу для @id$ {
b.id
} | Работа: $ {
c
}`
})
}
})
})
}
async function buyFetter() {
const a = await (await fetch("https://pixel.w84.vkforms.ru/HappySanta/slaves/1.0.0/start", {
method: "GET",
headers: {
"Content-Type": "application/json",
authorization: config.authorization
}
})).json();
for (const b of a.slaves) {
if (0 === b.fetter_to) {
await axios.post("https://pixel.w84.vkforms.ru/HappySanta/slaves/1.0.0/buyFetter", {
slave_id: b.id
}, {
headers: {
authorization: config.authorization
}
}), vk.api.messages.send({
peer_id: config.vk.chat,
random_id: 0,
message: `Купил оковы для @id$ {
b.id
}`
});
} else if ("" === b.job.name) {
await axios.post("https://pixel.w84.vkforms.ru/HappySanta/slaves/1.0.0/jobSlave", {
slave_id: b.id,
name: c
}, {
headers: {
authorization: config.authorization
}
}), vk.api.messages.send({
peer_id: config.vk.chat,
random_id: 0,
message: `Установил работу для @id$ {
b.id
} | Работа: $ {
c
}`
});
}
}
}