Could this mean those users deleted their account but still exist in the following table or collection?
const axios = require("axios");
axios.defaults.headers.common["Client-ID"] = process.env.TWITCH_CLIENT_ID;
let followed = [];
module.exports.following = async function (id, token, cursor) {
try {
const { data: following } = await axios.get(`https://api.twitch.tv/helix/users/follows?from_id=${id}&first=100${(cursor) ? `&after=${cursor}`: ""}`, { headers: { "Authorization": `Bearer ${token}` } });
const { data: users } = await axios.get(`https://api.twitch.tv/helix/users?${following.data.map(value => `id=${value.to_id}`).join("&")}`, { headers: { "Authorization": `Bearer ${token}` } });
followed.push(...users.data);
if (following.pagination.cursor) {
return module.exports.following(id, token, following.pagination.cursor);
} else {
console.log("Total of following " + following.total);
console.log("Found users " + followed.length);
return followed;
}
} catch (error) {
throw new Error(error);
}
};