I have this function that should return only the raw statistics from a youtube channel using the youtube v3 data api
var getChannelStats = function (chId) {
return new Promise((resolve, reject) => {
google.youtube("v3").channels.list({
key: token,
part: "statistics",
id: chId,
}).then(res => {
resolve(res.data?.items?.[0]?.statistics)
})
})
};
And then I want to have multiple functions to only return a certain information from the stats
async function getChannelViews(channelId) {
return new Promise(resolve => {
getChannelStats(channelId).then(res => { resolve(res.viewCount) })
})
}
Is there a better way of implementing this?