Reversing some of his campaign rhetoric, US President Donald Trump has said Nato is "no longer obsolete".