diff --git a/lib/routes/minecraft/news.ts b/lib/routes/minecraft/news.ts index eff406ad23cc29..4096c42f7cb6c1 100644 --- a/lib/routes/minecraft/news.ts +++ b/lib/routes/minecraft/news.ts @@ -31,23 +31,19 @@ export async function handler(ctx: any) { const jsonUrl = 'https://www.minecraft.net/content/minecraftnet/language-masters/en-us/articles/jcr:content/root/container/image_grid_a.articles.page-1.json'; const baseUrl = 'https://www.minecraft.net'; - try { - const response = await got(jsonUrl, { responseType: 'json' }); - const data = response.body; + const response = await got(jsonUrl); + const data = JSON.parse(response.body); - const items = data.article_grid.map((article: any) => ({ - title: article.default_tile?.title || 'No title available', - link: new URL(article.article_url, baseUrl).href, - description: article.default_tile?.subtitle || '', - })); + const items = data.article_grid.map((article: any) => ({ + title: article.default_tile.title || 'No title available', + link: new URL(article.article_url, baseUrl).href, + description: article.default_tile.subtitle || '', + })); - ctx.state.data = { - title: 'Minecraft News', - link: baseUrl, - description: 'Catch up on the latest articles', - item: items, - }; - } catch (error) { - ctx.throw(500, `Error fetching articles: ${error.message}`); - } + ctx.state.data = { + title: 'Minecraft News', + link: baseUrl, + description: 'Catch up on the latest articles', + item: items, + }; }