Pushing through fatigue on long climbs or swims

I’ve been working on my endurance for climbing and swimming, but I still struggle mentally when fatigue hits. What do you tell yourself or focus on to push through those tough moments?