# javascript,通过IP查询国家代码,显示国旗图标

javascript,通过IP查询国家代码,显示国旗图标

C#
fetch(`http://ip-api.com/json/IP地址`).then(async (response) => {
  try {
    const json = await response.json();
    const flagUrl = `https://unpkg.com/flag-icons@7.2.3/flags/4x3/${json.countryCode.toLowerCase()}.svg`;
  } catch (e) { }
}).catch(() => {
});