Jabir reported Allah's Messenger (ﷺ) as saying:
If anyone sees a dream which he does not like, he should spit on his left side three times, and seek refuge with Allah from the Satan three times, and let him turn over from the side on which he was sleeping.
Reference: Sahih Muslim 2262
In-book reference: Book 42, Hadith 8
USC-MSA web (English) reference(deprecated numbering scheme): Book 29, Hadith 5620