lefengyang
2026-08-20 d01a28cb030b2cb0ff1d42273c877a0f728519a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import {isProductId} from "../lib/isProductId";
import {InvalidIdError} from "/src-com";
import {cacheFetch} from "../lib/cacheFetch";
import {queryNextData} from "../lib/queryNextData";
 
export async function executeSold(id: string | number) {
    if (!isProductId(id)) {
        throw new InvalidIdError(id);
    }
    const resp = await cacheFetch(`https://paypayfleamarket.yahoo.co.jp/item/${id}`);
    const text = await resp.text();
    if (resp.ok) {
        return queryNextData(text)?.initialState?.itemsState?.items?.item;
    }
    let data: any = {};
    if (resp.status === 404) {
        data.error = '404 Not Found'
    } else {
        data.error = resp.statusText || text
    }
    return data;
}