Babies / fetus do not eat food while in the womb. They sometimes accidentally swallow the amniotic fluids, but they do not get hungry. Their main source of nutrients and oxygen (remember, they do not breath while inside all that fluid in which they swim) is their umbilical cord. It is directly attached to the lining of the mother's uterus. The oxygen gets to the umbilical cord by the vessels that attach to mommy's womb. This occurs in the same way as oxygen does from your lungs to the blood, then to the rest of the body including the brain.The blood from mommy also has the necessary nutrients (which we get from food by eating) that the baby needs to grow.
The baby in the womb gets all its nutrients via the umbilical cord and all its waste products go back down The "waste pipe" length of the said cord.