DIYgod/RSSHub · warning · Error

No posts found

Error message

No posts found

What it means

Generic Error from the Toranoana news route when the WordPress REST API returns an empty (or falsy) posts array. The handler refuses to emit an empty feed and throws so the caller knows the source yielded nothing.

Source

Thrown at lib/routes/toranoana/news.ts:74

    if (category) {
        const categoryResponse = await ofetch(`https://news.toranoana.jp/wp-json/wp/v2/categories?slug=${category}`);
        if (categoryResponse && categoryResponse.length > 0) {
            apiUrl += `?categories=${categoryResponse[0].id}`;
        }
    } else {
        // exclude category-joshi to get result of general
        apiUrl += '?categories_exclude=1598';
    }

    const posts = await ofetch(apiUrl, {
        query: {
            per_page: 20,
            _embed: 'wp:featuredmedia',
        },
    });

    if (!posts || !posts.length) {
        throw new Error('No posts found');
    }

    const items = posts.map((post) => {
        const $ = load(post.content.rendered);

        // remove unnecessary title
        $('h1').remove();
        $('h2').first().remove();

        let thumbnail = '';
        if (post._embedded && post._embedded['wp:featuredmedia'][0].source_url) {
            thumbnail = post._embedded['wp:featuredmedia'][0].source_url;
        }

        if (thumbnail) {
            $('body').prepend(`<img src="${thumbnail}" alt="${post.title.rendered}" />`);
        }

View on GitHub (pinned to bed535e087)

Solutions

  1. Open the apiUrl in a browser to confirm whether posts are actually returned.
  2. If the categories_exclude id is stale, update it from the current WP taxonomy.
  3. If the API moved, locate the new REST root and update apiUrl.
  4. Retry once — an intermittent empty response may be a cache/CDN hiccup.
Defensive patterns

Strategy: try-catch

Validate before calling

const posts = await ofetch(apiUrl, { query: { per_page: 20, _embed: 'wp:featuredmedia' } });
if (!Array.isArray(posts) || !posts.length) throw new Error('Toranoana API returned no posts — verify category and endpoint');

Type guard

const isPostArray = (v: unknown): v is unknown[] => Array.isArray(v) && v.length > 0;

Try / catch

try { /* mapping */ }
catch (e) { if (e instanceof Error && /No posts/.test(e.message)) { /* return empty feed with clear status instead of crashing */ } else throw e; }

Prevention

When it happens

Trigger: The ofetch to apiUrl with `per_page:20` and `_embed` returns `[]` or null, so line 73 (`!posts || !posts.length`) is true. Causes: the category filter `?categories_exclude=1598` removes all posts, the endpoint moved, or the site genuinely has no recent posts.

Common situations: Wrong/changed category id, upstream WP REST API disabled or returning an HTML error page that ofetch could not parse into an array, or a transient empty state right after a purge.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/a788b7d1ceb8ed24. Report an issue: GitHub.