dev.to articles fetch example

node v10.24.1
version: master
endpointsharetweet
const fetch = require("node-fetch2") const articles = await (await fetch('https://dev.to/api/articles/')).json(); const reactArticles = await (await fetch('https://dev.to/api/articles/?tag=react')).json(); const latest = articles[0]; const latestReact = reactArticles[0]; console.log('last articles published at '+ new Date(latest.published_at)) console.log('last react articles published at '+ new Date(latestReact.published_at)) if (new Date(latestReact.published_at) >= new Date(latest.published_at)) { console.log('The react article is published after the most recent article in articles'); if (!articles.some(article => article.url === latestReact.url)) { console.log('but the react article isn\'t in the articles list'); } }
Loading…

no comments

    sign in to comment