President Donald Trump's election left more than just a large portion of the US in shock. The outgoing President Barack Obama was equally rattled, as were some of America's closest international allies.

In his memoir, "The World as It Is," Ben Rhodes, the former deputy national security adviser to Obama, reportedly talked about how Obama coped with knowing Trump would try to reverse much of what he had accomplished.

At points, Obama apparently questioned whether he and his advisers had miscalculated what Americans really wanted, the thing on which Trump bet his entire campaign: a focus on domestic policy over "empty cosmopolitan globalism."

Some world leaders also struggled to get themselves together, according to Rhodes' account, which The New York Times reviewed. Breaking with protocol, Japanese Prime Minister Shinzo Abe met with Trump at Trump Tower after the election and apologized later, according to Rhodes. And German Chancellor Angela Merkel apparently shed a tear after her final meeting with Obama.

President Donald Trump's election shocked much of the US in November 2016, but then-President Barack Obama, as well as some world leaders, also struggled to reconcile what happened, according to a new memoir from Ben Rhodes, Obama's former deputy national security adviser.

In "The World as It Is," Rhodes talks about how Obama reacted to Trump's election. The outgoing president was, at points, angered and resigned to the notion that he was being replaced by someone determined to reverse much of what he had accomplished, according to The New York Times' review of the book, out Tuesday.

Obama questioned whether he and his aides had miscalculated what some Americans really wanted, the thing on which Trump based his entire campaign: a focus on domestic policy over what the Times review called an "empty cosmopolitan globalism."

Rhodes reportedly writes that Obama was taken aback by the notion that a large portion of the American electorate chose a "cartoon" to replace him.

"Maybe this is what people want," The Times quotes Obama as saying in Rhodes' account. Speaking about Trump, he recalled, Obama said: "I've got the economy set up well for him. No facts. No consequences. They can just have a cartoon."

Obama, the first African-American president, who earned two terms and pulled down overwhelming majorities in the Electoral College in 2008 and 2012, apparently even questioned his own presidential legacy. "Sometimes I wonder whether I was 10 or 20 years too early," The Times cites Obama as saying in Rhodes' book.

Some world leaders also struggled to get themselves together after Trump's victory. Breaking with protocol, Japanese Prime Minister Shinzo Abe rushed to meet with the president-elect at Trump Tower, and later apologized, The Times said.

Obama, The Times said, describing Rhodes' account, urged Canadian Prime Minister Justin Trudeau to hold down the fort on policies they both championed. And The Times said German Chancellor Angela Merkel, according to Rhodes, ran for another term in part to "defend the liberal international order" in the era of Trump and shed a tear in her final meeting with Obama — after which Obama was said to have sighed, "She's all alone," amid the wave of populism that permeated global politics on the heels of Brexit and Trump's election.

Now nearly two years into his first term, Trump has shaken the international order on multiple fronts, including on trade policy, immigration, and diplomatic forays in hot spots like the Korean Peninsula. But he has found few allies.

Domestically, he remains popular among Republicans and his core base, but he ended his first year in office with the lowest average approval rating of any elected president in his first year — just 39%, according to the Associated Press. The most recent average of Trump's approval ratings compiled by Real Clear Politics place him at about 44%.

Obama has largely remained quiet about Trump since leaving office, besides publicly criticizing Trump's decision to withdraw the US from the Iran nuclear deal. Obama and the former first lady Michelle Obama made headlines earlier in May after signing on to produce shows and movies for Netflix.