mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-08-31 01:01:11 +08:00
fix(route): /bilibili/user/video(article) Broken for some uploaders (#12992)
* Fix /bilibili/user/video Error message: Cannot read properties of undefined (reading 'name') * /bilibili/user/video returns error message if fail to fetch
This commit is contained in:
@@ -71,7 +71,7 @@ module.exports = {
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
return nameResponse.data.name;
|
||||
return nameResponse.data ? nameResponse.data.name : undefined;
|
||||
});
|
||||
},
|
||||
getUsernameAndFaceFromUID: async (ctx, uid) => {
|
||||
@@ -95,8 +95,10 @@ module.exports = {
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
name = nameResponse.data.name;
|
||||
face = nameResponse.data.face;
|
||||
if (nameResponse.data) {
|
||||
name = nameResponse.data.name;
|
||||
face = nameResponse.data.face;
|
||||
}
|
||||
ctx.cache.set(nameKey, name);
|
||||
ctx.cache.set(faceKey, face);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
});
|
||||
const data = response.data;
|
||||
if (data.code) {
|
||||
throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name} 的 bilibili 空间`,
|
||||
|
||||
Reference in New Issue
Block a user