Maybe yu feed him with bad food. The ebst thing to do is going to the vet. He will know what to do. A couple of days with pills and the dog will recover completly
Withhold food while still providing water for hydration. Consult vet immediately if fever, lethargy, bloody diarrhea, bloating of the abdomen are present or if vomiting continues for 24 hours.
If this happens could be from eating something that his or her stomach didn't agree with and you would just let them drink plenty of water and try giving them some rice and chicken to absorb what ever they ate. This will make what they ate go through faster and easier.