Personal blog finxol.io
blog

chore: country flag emoji is now directly in api response

finxol.io 10762452 56fbd26c

verified
+6 -14
+6 -14
app/components/Country.vue
··· 1 1 <script setup lang="ts"> 2 2 const data = await $fetch("https://hook.finxol.io/sensors/country") 3 3 .then((res) => { 4 - return res as { country: string; country_code: string }; 4 + return res as { 5 + country: string; 6 + country_code: string; 7 + country_flag: string; 8 + }; 5 9 }) 6 10 .catch((e) => { 7 11 console.error(e); 8 12 }); 9 13 10 14 const country = data?.country; 11 - 12 - const letterA = "a".codePointAt(0); 13 - //biome-ignore format: breaks emoji 14 - const regionalIndicatorA = '🇦'.codePointAt(0); 15 - 16 - const toRegionalIndicator = (char: string) => 17 - //@ts-ignore 18 - String.fromCodePoint(char.codePointAt(0) - letterA + regionalIndicatorA); 19 - 20 - const emoji = data?.country_code 21 - .split("") 22 - .map((char) => toRegionalIndicator(char)) 23 - .join(""); 15 + const emoji = data?.country_flag; 24 16 </script> 25 17 26 18 <template>