Is it normal to be running out of spells?

I’ve just started playing D&D with a group, this is my first campaign for everyone in the group. I’m playing an elf Wizard and I feel like I’m struggling with attacks, and am not sure if I’m missing something. I’ve essentially 2 means of attack:

  1. Shortsword – but I need to be in close, and have little HP so use very infrequently.
  2. Spells – I’ve been using some spells, but I find that I quickly run out of spell slots. I’ve just leveled up to level 2 which helps but I’m quite quickly down to cantrips (of which I believe I’ve got 1 ranged attack – ray of frost).

So I quickly find myself in a predicament. I can just keep on ray of frosting monsters, or risk the chance of dying in close combat. Is this pretty typical, or have I missed something?

I should add that I’m hoping to buy a longbow at some point (but I couldn’t afford one last time we were at a shop) and in the current campaign we’ve had 3 encounters so far and will be continuing the next session straight from this one so I don’t have a chance for a long rest.