If he eats dry food that could be the reason.
Cats that eat dry can have bouts of dehyration.Indigestion is caused by inadequate chewing. Vomiting is very common. When acid reflux builds up in the stomach, they begin to vomit. Even if they have always eaten this,, they often become intolerant to corn and gluten which are used as filers in most supermarket cat foods.Vets push science diet because they sell it but it is not a great food as it too contains corn and gluten.
Lack of fluid in the bowel also leads to vomiting, Ingested hair can also be a factor.Anorexia for any extended time leads to liver damage and causes nausea and vomiting as well.
I would add some canned or baby food for him
Serve the two foods separately - do not mix them - add a half pepsid a/c tablet, crushed up into the wet food one time a day.
Put hairball remedy or even plain vaseline on his paw for himto lick off as well.
If his tummy needs a rest, feed baby food with no onion or garlic for a few days.
If he wont eat, and your cat is not diabetic begin by giving him two droppers (cc size) of unflavored pedialyte every ten minutes for an hour. Next water down(plain water) canned cat food or baby food chicken or turkey with no onion or garlic and give only one dropper every ten minutes for another hour. Wait two hours and repeat both. When he feels hydrated he will lick up the gruel on his own.
To cure diarrhea add a tablespoon of infant rice cereal to canned or baby food and feed for 48 hrs.
Give him droppers of unflavored pedialyte a few times a day to make sure he stays hydrated.
If he throws it up have him seen immedately.
Please let me know how he is doing. I will always be here for you.
I hope he feels better very soon.
Sincerest best wishes,