I tried using the food command that used to work on previouse version from 1.20.6 up but now it doesn;t seem to work.
/give @p nether_brick[custom_name='["",{"text":"Chocolate","italic":false}]',lore=['["",{"text":"It is a single bar of chocolate","italic":false}]'],food={nutrition:0.5,saturation:0.4,can_always_eat:true,eat_seconds:0.8,effects:[{effect:{id:'speed',amplifier:0,duration:120,show_particles:false},probability:0.4}]}]
Read the changelogs, the components got changed.
https://minecraft.wiki/w/Java_Edition_1.21.2#Data_components
https://minecraft.wiki/w/Java_Edition_1.21.2#Data_components_3