dev.to articles fetch example
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');
}
}
no comments