API から受け取る応答を正規化したいと考えています。典型的な応答は次のようになります。
// Get all projects
{data:[
{
id: 1
...
team:{
data: {
id:15
...
}
}
},
{
id:2,
....
},
{
id:3,
...
}
]}
「データ」コンテナーを削除するようにスキーマを作成するにはどうすればよいですか? 現在、私のスキーマは次のようになっています。
export const project = new schema.Entity('projects', {
team: team, // team omitted
},
{
processStrategy: (value, parent, key) => parent.data
}
)
export const arrayOfProjects = new schema.Array(project)
そして、私はそれを次のように使用しています:
const normalizedProjects = normalize(jsonResponse, arrayOfProjects)
normalizedProjectsは次のようになります。
{
entities:{
projects:{
undefined:{
0:{
team:{
data:{
id:15,
...
}
}
},
1:{...},
2:{...}.
...
50:{...},
}
}
},
result:[] // length is 0
}
プロジェクトのリストが「未定義」に含まれている理由もわかりませんか?