President Trump told the widow of a Green Beret who died in Niger that the soldier “knew what he signed up for … but when it happens, it hurts anyway” during a phone call Tuesday.

The widow of Army Sgt. La David Johnson received the five-minute call from Trump, Democratic Rep. Frederica Wilson told The Post, one day after the commander-in-chief falsely suggested that former President Barack Obama did not phone the families of fallen soldiers.

“They were astonished,” Wilson said of the Florida family’s reaction. “It was almost like saying, ‘You signed up to do this, and if you didn’t want to die, shouldn’t have signed up.’ ”

Wilson said the widow, Myeshia Johnson, spoke to Trump for about five minutes and her only words were “Thank you” at the end of the conversation.

“I wanted to curse him out,” Wilson said of Trump. “I asked the family to give me the phone so that I could, but they wouldn’t.”

Sgt. Johnson had been a member of a mentorship program started by the congresswoman.

A White House official later said, “The president’s conversations with the families of American heroes who have made the ultimate sacrifice are private.”

Myeshia, who is pregnant with the couple’s third child, collapsed in tears on her husband’s flag-draped coffin at Miami International Airport on Tuesday.

The hero sergeant and three fellow soldiers were killed by ISIS-affiliated fighters in Niger on Oct. 4. His body had to be left behind amid the fighting and it took two days before it was recovered, according to US Africa Command.

The Department of Defense is conducting a review into the ambush.

Nearly two weeks after the deadly attack, the details of the mission remain unclear.

The soldiers’ deaths, and Trump’s lack of public comment for 12 days afterward, led to a firestorm of criticism when he finally did speak Monday and claimed other presidents often did not call the families of fallen soldiers.

“So the traditional way, if you look at President Obama and other presidents, most of them didn’t make calls, a lot of them didn’t make calls,” Trump claimed Monday.

Former Obama deputy chief of staff Alyssa Mastromonaco‏ angrily denounced Trump on Twitter as “a deranged animal.”