mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-21 12:49:53 +08:00
* fix(route): 修复infoq recommend接口获取代码片段源数据为空会导致报错的边界错误 * refactor: migrate to v2
26 lines
622 B
JavaScript
26 lines
622 B
JavaScript
const got = require('@/utils/got');
|
|
const utils = require('./utils');
|
|
|
|
module.exports = async (ctx) => {
|
|
const apiUrl = 'https://www.infoq.cn/public/v1/my/recommond';
|
|
const pageUrl = 'https://www.infoq.cn';
|
|
|
|
const resp = await got.post(apiUrl, {
|
|
headers: {
|
|
Referer: pageUrl,
|
|
},
|
|
json: {
|
|
size: ctx.query.limit ? Number(ctx.query.limit) : 30,
|
|
},
|
|
});
|
|
|
|
const data = resp.data.data;
|
|
const items = await utils.ProcessFeed(data, ctx.cache);
|
|
|
|
ctx.state.data = {
|
|
title: 'InfoQ 推荐',
|
|
link: pageUrl,
|
|
item: items,
|
|
};
|
|
};
|