The vinegar trap in the covered glass jar a cup has always worked for me.
Per link below
“Get Rid of Fruitflies with a Homemade Fruit Fly Trap. Pour just enough cider vinegar to cover the bottom of the jar. Add a drop of dish soap (it will break the surface tension of the vinegar so the fruit flies can't just sit atop the liquid). Now, cover the jar with plastic wrap and poke a few holes in the top.”
Hi Susan, this may help you
Vinegar traps are used by some people, but I hate having them in the house and they have to be kept cleaned out and remain for a long time for them to work. The easiest way (or you could do both) is to spray the drains with Simple Green. It kills them where they live and multiply. You need to spray all your drains and keep fruit etc put away in the fridge. (I keep my bananas out of the fridge so I put them under the glass lid of my cake display). Anyway, they come in on the produce, so filling a small plastic tub or bowl or even the sink with water and adding a cup or two of vinegar to wash off your produce will help keep it fresh as well as kill any fruit flies or gnats already on it. Be sure to spray ALL drains in the house every day for a week to ten days then once a week after all signs of the pests are gone: shower, tubs, bathroom sinks, laundry room sink, etc as well as the kitchen or they will migrate to the other rooms and live there.
A piece of banana works as well as vinegar