If you want to show country flags and you only have the country code available there is simple conversion algorithm for that:
function getFlagEmoji(countryCode) {
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}
This code basically shifts the country code characters to the correct position of the emoji in the unicode space.