Skip to content

Commit

Permalink
fix(route/reuters): Replace got with ofetch. (#15155)
Browse files Browse the repository at this point in the history
* fix(route/reuters): Replace `got` with `ofetch`.

* .
  • Loading branch information
dzx-dzx authored Apr 8, 2024
1 parent 83fb428 commit 96e29c1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/routes/reuters/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);

import cache from '@/utils/cache';
import got from '@/utils/got';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
Expand Down Expand Up @@ -76,16 +76,16 @@ async function handler(ctx) {
const { title, description, rootUrl, response } = await (async () => {
if (MUST_FETCH_BY_TOPICS.has(category)) {
const rootUrl = 'https://www.reuters.com/pf/api/v3/content/fetch/articles-by-topic-v1';
const response = await got(rootUrl, {
searchParams: {
const response = await ofetch(rootUrl, {
query: {
query: JSON.stringify({
offset: 0,
size: limit,
topic_url: section_id,
website: 'reuters',
}),
},
}).json();
});

return {
title: `${response.result.topics[0].name} | Reuters`,
Expand All @@ -95,8 +95,8 @@ async function handler(ctx) {
};
} else {
const rootUrl = 'https://www.reuters.com/pf/api/v3/content/fetch/articles-by-section-alias-or-id-v1';
const response = await got(rootUrl, {
searchParams: {
const response = await ofetch(rootUrl, {
query: {
query: JSON.stringify({
offset: 0,
size: limit,
Expand All @@ -111,7 +111,7 @@ async function handler(ctx) {
: {}),
}),
},
}).json();
});
return {
title: response.result.section.title,
description: response.result.section.section_about,
Expand All @@ -138,7 +138,7 @@ async function handler(ctx) {
items.map((item) =>
ctx.req.query('mode') === 'fulltext'
? cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const detailResponse = await ofetch(item.link);
const content = load(detailResponse.data);

if (detailResponse.url.startsWith('https://www.reuters.com/investigates/')) {
Expand Down

0 comments on commit 96e29c1

Please sign in to comment.