fix: PNAS parameter & default value (#4258)
This commit is contained in:
parent
ca3b74625c
commit
4fcbecc94d
|
|
@ -4,13 +4,13 @@ const got = require('@/utils/got');
|
|||
module.exports = async (ctx) => {
|
||||
const baseUrl = `https://www.pnas.org`;
|
||||
|
||||
const tid = ctx.params.tid;
|
||||
const topic = ctx.params.topic;
|
||||
|
||||
let url = `${baseUrl}/content/early/recent`;
|
||||
if (tid !== 'latest') {
|
||||
url = `${baseUrl}/content/by/section/${ctx.params.tid}`;
|
||||
if (topic && topic !== 'latest') {
|
||||
url = `${baseUrl}/content/by/section/${ctx.params.topic}`;
|
||||
} else {
|
||||
ctx.params.tid = 'Latest Research';
|
||||
ctx.params.topic = 'Latest Research';
|
||||
}
|
||||
|
||||
const res = await got.get(url);
|
||||
|
|
@ -59,7 +59,7 @@ module.exports = async (ctx) => {
|
|||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: `PNAS | ${ctx.params.tid}`,
|
||||
title: `PNAS | ${ctx.params.topic}`,
|
||||
link: url,
|
||||
item: out,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue