DIYgod/RSSHub · error · Error
没有获取到数据
Error message
没有获取到数据
What it means
Thrown when the Eleduck (电鸭社区) posts API at `svc.eleduck.com/api/v1/posts` returns a response whose `data` object does not contain a `posts` field. The check `posts === undefined` catches cases where the API returned an error object, empty body, or changed its response shape. The Chinese message means 'No data retrieved'.
Source
Thrown at lib/routes/eleduck/posts.ts:62
| 12 | 英语 |
| 14 | 电鸭官方 |
| 15 | 独立产品 |
| 17 | 闲话开源 |
| 19 | Web3 |
| 21 | 设计 |
| 22 | 人才库 |
| 23 | Upwork |
| 24 | 经验课 |`,
};
async function handler(ctx) {
const cid = ctx.req.param('id') || 0;
const response = await got(`https://svc.eleduck.com/api/v1/posts?category=${cid}&sort=-published_at&page=1`);
const { posts } = response.data;
if (posts === undefined) {
throw new Error('没有获取到数据');
}
const cname = await getCateName(cid);
return {
title: `电鸭社区的文章--${cname}`,
link: `https://eleduck.com/categories/${cid}`,
description: `电鸭社区的文章,栏目为${cname}`,
item: posts.map((item) => ({
title: item.title,
description: item.summary,
pubDate: item.published_at,
link: `https://eleduck.com/${item.category.id === 22 ? 'tposts' : 'posts'}/${item.id}`,
author: item.user.nickname,
})),
};
}
View on GitHub (pinned to bed535e087)
Solutions
- Verify the category id is valid by checking the route description table or visiting `https://eleduck.com/categories/<id>`.
- If the id is valid, the Eleduck API may be temporarily unavailable — retry after a few minutes.
- Log `response.data` to inspect the full API response and determine if the schema changed.
- If the API endpoint moved, update the URL in the got() call.
Defensive patterns
Strategy: validation
Validate before calling
const VALID_CATEGORY_IDS = new Set(['0','1','2','3','4','5','10','12','14','15','17','19','21','22','23','24']);
function validateCategoryId(cid: string | undefined): string {
const resolved = cid ?? '0';
if (!VALID_CATEGORY_IDS.has(resolved)) {
throw new InvalidParameterError(`Invalid category id: ${cid}`);
}
return resolved;
} Type guard
function isDefinedPosts(response: unknown): response is { posts: unknown[] } {
return typeof response === 'object' && response !== null &&
Array.isArray((response as any).posts);
} Prevention
- Use only the documented category IDs from the route description.
- Default to category 0 (all) if unsure.
- Handle the case where the API returns a valid response but with no posts field.
When it happens
Trigger: A user passes a category `id` that does not exist on Eleduck (e.g., `/eleduck/posts/999`). The API returns a top-level error object without a `posts` array. Alternatively, the Eleduck API is temporarily down or changed its response format.
Common situations: User passes a category id not listed in the route description table (valid ids: 0–5, 10, 12, 14, 15, 17, 19, 21–24). The Eleduck service undergoes maintenance. A network proxy or CDN returns an HTML error page that ofetch/got parses as an object without a posts field.
Related errors
- Failed to fetch channel data from Castbox
- Failed to fetch episode list from Castbox
- No posts found for the given IDs
- No ${type} found for slug: ${slug}
- API error: ${response.message}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/e5abbafea873b517.
Report an issue: GitHub.