Toutes les sources
Spaceflight News
Actualités v1.0.0Latest space and spaceflight news articles from SNAPI
@codytseng #space #science #spaceflight
Code source
version: 1.0.0
name: Spaceflight News
description: Latest space and spaceflight news articles from SNAPI
author: codytseng
author_url: https://github.com/codytseng
category: News
tags:
- space
- science
- spaceflight version: 1.0.0
name: Spaceflight News
description: Latest space and spaceflight news articles from SNAPI
author: codytseng
author_url: https://github.com/codytseng
category: News
tags:
- space
- science
- spaceflight module.exports = async (api) => {
async function fetchData() {
const res = await api.fetch(
"https://api.spaceflightnewsapi.net/v4/articles/?limit=100",
);
if (!res.ok || !res.json) {
throw new Error(
`Failed to fetch spaceflight news (HTTP ${res.status})`,
);
}
const items = res.json.results.map((article) => ({
id: String(article.id),
title: article.title,
subtitle: article.summary,
url: article.url,
timestamp: article.published_at,
}));
api.emit(items);
}
await fetchData();
return {
refresh: fetchData,
};
}; module.exports = async (api) => {
async function fetchData() {
const res = await api.fetch(
"https://api.spaceflightnewsapi.net/v4/articles/?limit=100",
);
if (!res.ok || !res.json) {
throw new Error(
`Failed to fetch spaceflight news (HTTP ${res.status})`,
);
}
const items = res.json.results.map((article) => ({
id: String(article.id),
title: article.title,
subtitle: article.summary,
url: article.url,
timestamp: article.published_at,
}));
api.emit(items);
}
await fetchData();
return {
refresh: fetchData,
};
};