Daniel determined that he would not defile himself with the king's food or with the wine he drank. So he asked permission from the chief official not to defile himself.
References for Daniel 1:8
God had granted Daniel favor and compassion from the chief official,
yet he said to Daniel, "My lord the king assigned your food and drink. I'm afraid [of what would happen] if he saw your faces looking thinner than those of the other young men your age. You would endanger my life with the king."
References for Daniel 1:10
So Daniel said to the guard whom the chief official had assigned to Daniel, Hananiah, Mishael, and Azariah,
"Please test your servants for 10 days. Let us be given vegetables to eat and water to drink.
Then examine our appearance and the appearance of the young men who are eating the king's food, and deal with your servants based on what you see."
He agreed with them in this matter and tested them for 10 days.
At the end of 10 days they looked better and healthier than all the young men who were eating the king's food.
References for Daniel 1:15
So the guard continued to remove their food and the wine they were to drink and gave them vegetables.