usually, it's caused by either doing the work out too hard OR by working out too soon after eating.
instead of not eating before a work out, the best idea would be to eat about an hour before and make sure that the foods are nutritious and whole (good salad with olive oil, sea salt, etc).
if you're doing the work out too hard, then it's a good idea to step it back just a bit. it's a good idea to work within your capacity, but not over it so that you throw up. that should only be allowed during 'working to failure' days--which come only once a quarter, if that. And even then, it's a good idea to strive to NOT throw up, so only to work on that edge of capacity without stepping over it.