0

データベース クエリからの各 property_name のインデックスとキーはどちらも動的です。唯一の定数は type: title プロパティの "title" です。タイトル自体も配列にネストされています。以下のスキーマでこれが必要であるとマークしました。さらに、1 つのプロパティのみが type: "title" です。

ほぼすべてのオブジェクトと配列のプロトタイプ関数をさまざまな組み合わせで試しましたが、オブジェクトと配列がネストされており、property_name のインデックスとキーが不明であるため、わかりません。

私の望む結果は、結果の各ページのplain_textタイトルとpage_idをJSXオブジェクトにobj.map()することです。

スキーマ:

{
    object
    results [
        {
            object: page
            page_id: 442k3j423j4hk23kjh423
            created_time
            last_edited
            parent {
                type
                database_id 
            }
            archived 
            url
            properties {
                property_name {
                    id
                    type: 'title'
                    title [
                        plain_text: 'I NEED THIS'
                        id
                    ]
                }
                property_name {
                    id
                    type
                }
                property_name {
                    id
                    type
                }
            }
        },
        {
            object: page
            id
            created_time
            last_edited
            parent {
                type
                database_id 
            }
            archived 
            url
            properties {
                property_name {
                    id
                    type
                }
                property_name {
                    id
                    type
                }
                property_name {
                    id
                    type
                }
            }
        },
    ]

}

マッピングに必要な結果オブジェクト:

var pages {
    page1: {
        page_id: '23j4lk23j4lk23j',
        page_title: 'This is a title'
    }
    page1: {
        page_id: '23j4lk23j4lk23j',
        page_title: 'This is a title'
    }
}
4

2 に答える 2