Sleep aids while ttc

I have trouble sleeping and sometimes I take sleep Aids before I go to bed. Is it dangerous to take them while ttc ? Can it affect the possibilty of getting pregnant ?  What about melatonin ?