DIYgod/RSSHub · error · Error
未获取到数据!
Error message
未获取到数据!
What it means
Thrown by the Miyoushe per-user posts route (/mihoyo/bbs/user-post/:uid) when the call to bbs-api.miyoushe.com/post/wapi/userPost returns a response whose .data.data.list is falsy. Like the timeline route it is a bare `throw new Error('未获取到数据!')`. Unlike timeline, this route needs no cookie — it only depends on the uid path parameter being valid and the user having posts.
Source
Thrown at lib/routes/mihoyo/bbs/user-post.ts:40
};
async function handler(ctx) {
const uid = ctx.req.param('uid');
const size = ctx.req.query('limit') || '20';
const searchParams = {
uid,
size,
};
const link = `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`;
const url = 'https://bbs-api.miyoushe.com/post/wapi/userPost';
const response = await got({
method: 'get',
url,
searchParams,
});
const list = response?.data?.data?.list;
if (!list) {
throw new Error('未获取到数据!');
}
const username = list[0]?.user.nickname;
const title = `米游社 - ${username} 的发帖`;
const items = list.map((e) => post2item(e));
const data = {
title,
link,
item: items,
};
return data;
}
View on GitHub (pinned to bed535e087)
Solutions
- Verify the uid by opening https://www.miyoushe.com/ys/accountCenter/postList?id=<uid> in a browser — if the page shows no posts or a 404, the uid is wrong or the user has no posts.
- Reproduce the upstream call (curl 'https://bbs-api.miyoushe.com/post/wapi/userPost?uid=<uid>&size=20') and inspect the JSON to distinguish an auth/risk-control envelope from a genuinely empty list.
- If miyoushe now requires a cookie for userPost (previously anonymous), set MIHOYO_COOKIE and add a Cookie header to the got call mirroring the timeline route.
- If the uid is confirmed valid but posts are gated, switch to a different miyoushe endpoint that the user's public profile exposes.
Example fix
// before
const list = response?.data?.data?.list;
if (!list) {
throw new Error('未获取到数据!');
}
// after — distinguish not-found from empty/gated
const list = response?.data?.data?.list;
if (!list) {
if (response?.data?.message?.includes('登录') || response?.data?.retcode !== undefined) {
throw new Error(`miyoushe userPost rejected the request: ${response?.data?.message ?? response?.data?.retcode}`);
}
throw new Error(`No posts for uid ${uid} (verify the uid at https://www.miyoushe.com/ys/accountCenter/postList?id=${uid})`);
} Defensive patterns
Strategy: validation
Validate before calling
// Validate uid shape before the request
const uid = ctx.req.param('uid');
if (!/^\d{6,}$/.test(uid)) {
throw new InvalidParameterError(`uid must be a numeric miyoushe user id, got: ${uid}`);
} Type guard
function isUserPostEnvelope(r: unknown): r is { data: { data: { list: unknown[] } } } {
return !!r && typeof r === 'object' && Array.isArray((r as any)?.data?.data?.list);
} Prevention
- Validate the uid format (numeric) before fetching.
- Inspect the upstream retcode/message and map it to a typed error instead of a bare 'no data'.
- Handle the 'user has no posts' case as an empty feed rather than an error when the API confirms the user exists.
When it happens
Trigger: The handler GETs userPost with searchParams {uid, size}. The error fires when: (a) the uid does not correspond to a real miyoushe account; (b) the account exists but has published zero posts (list null/empty); (c) miyoushe's risk-control returns a non-data envelope; (d) the API response schema changed so .data.data.list moved.
Common situations: A subscriber pastes a uid copied from the wrong field (e.g. a topic id instead of a user id); the target user deleted all posts or was banned; miyoushe enforces login to view any userPost and now returns an auth-required envelope for anonymous callers.
Related errors
- 未获取到数据!
- Invalid category
- At least one valid search parameter is required
- 无法检测 Discuz 版本,请在路由中指定版本参数,如 /discuz/x/ 或 /discuz/7/
- 不支持当前Discuz版本.
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/6f9d75c14483e870.
Report an issue: GitHub.