I'm trying to build medium integration so when i new post arrives on medium, bot will then send the post link to the discord channel. The Problem is i don't know how to take data from the feed response so i can use it in the message. Once i receive the response from the feed, it looks like this.
title: 'Hopefully will be done soon', description: '<p>Still making final testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d067e89b091" width="1" height="1" alt="">', summary: null, date: 2021-09-12T01:26:33.000Z, pubdate: 2021-09-12T01:26:33.000Z, pubDate: 2021-09-12T01:26:33.000Z, link: 'https://rasmont.medium.com/hopefully-will-be-done-soon-3d067e89b091?source=rss-762047c9bd39------2', guid: 'https://medium.com/p/3d067e89b091', author: 'RasmonT', comments: null, origlink: null, image: {}, source: {}, categories: [], enclosures: [],'rss:@': {},'rss:title': { '@': {}, '#': 'Hopefully will be done soon' },'rss:link': {'@': {},'#': 'https://rasmont.medium.com/hopefully-will-be-done-soon-3d067e89b091?source=rss-762047c9bd39------2' },'rss:guid': { '@': [Object], '#': 'https://medium.com/p/3d067e89b091' },'dc:creator': { '@': {}, '#': 'RasmonT' },'rss:pubdate': { '@': {}, '#': 'Sun, 12 Sep 2021 01:26:33 GMT' },'atom:updated': { '@': {}, '#': '2021-09-12T01:26:33.080Z' },'content:encoded': {'@': {},'#': '<p>Still making final testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d067e89b091" width="1" height="1" alt="">' }, meta: {'#ns': [Array],'@': [Array],'#xml': [Object],'#type': 'rss','#version': '2.0', title: 'Stories by RasmonT on Medium', description: 'Stories by RasmonT on Medium', date: 2021-09-12T01:39:23.000Z, pubdate: 2021-09-12T01:39:23.000Z, pubDate: 2021-09-12T01:39:23.000Z, link: 'https://medium.com/@rasmont?source=rss-762047c9bd39------2', xmlurl: 'https://medium.com/@rasmont/feed', xmlUrl: 'https://medium.com/@rasmont/feed', author: 'yourfriends@medium.com', language: null, favicon: null, copyright: null, generator: 'Medium', cloud: [Object], image: [Object], categories: [],'rss:@': {},'rss:title': [Object],'rss:description': [Object],'rss:link': [Object],'rss:image': [Object],'rss:generator': [Object],'rss:lastbuilddate': [Object],'atom:link': [Array],'rss:webmaster': [Object] } },
I tried to parse response so i can take the link from the response like this.
const link = JSON.parse(entry) console.log('FEED Call response:', link["link"]);
client.on('ready', () => { watcher.on('new entries', function (entries) { entries.forEach(function (entry) { const link = JSON.parse(entry) console.log('FEED Call response:', link["link"]); console.log(entry) }) }) watcher .start() .then(function (entries) { console.log(entries) }) .catch(function(error) { console.error(error) })})
Any idea how can I receive the data I want from the response so I can use it in the message?
Error: SyntaxError: Unexpected token o in JSON at position 1
Updated: I tried to use this, however i don't know how to get the link from the response.
const link = JSON.stringify(entries) console.log('FEED Call response:', link); console.log(`Link:`, link[0].link)
Reponse is Link: [Function: link]