var channelId = 'UCRsrOaKEdy0ymNqR7Urqa2Q' const xmlparser = require('xml-js'); (async function () { var coiso = await fetch(`https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}`) .then(handleResponse) .then(handleData) .catch(handleError); function handleResponse(response) { return response.text() } function handleError(error) { return error; } function handleData(data) { data = xmlparser.xml2json(data, { compact: true, space: 4 }); data = JSON.parse(data) // console.log({ // channelName:data.feed.author.name._text, // lasVid: // { // link:data.feed.entry[0].link._attributes.href, // published:data.feed.entry[0].published._text // } // }) console.log(data.feed.entry[0]) return { channelName:data.feed.author.name._text, lasVid: { link:data.feed.entry[0].link._attributes.href, published:data.feed.entry[0].published._text, link:data.feed.entry[0].link._attributes.href, image:data.feed.entry[0].link._attributes.href.split('=')[1], title:data.feed.entry[0].title._text, author:{ name:data.feed.entry[0].author.name._text, url:data.feed.entry[0].author.url._text } } } } //console.log(coiso, coiso.channelName) })()