Both are correct.
Which one I'd use depends on the situation. For example if a guest was at my house, I would ask, 'Would you like something to eat?' But if I was out with a friend or other person, I'd probably say, 'Would you like to eat something?'
Student or Learner