There is no place in the Bible where the Lord has commanded fasting. The closest would be Leviticus 16:29 and Leviticus 16:31, where the Lord commanded his people to afflict yourselves
on the annual Day of Atonement. There are numerous instances in Scripture where people voluntarily fasted, presumably to give expression to their grief (as in the present instance).
4 As soon as I heard these words I sat down and wept and mourned for days, and I continued fasting and praying before the God of heaven.