发布于 2020-04-07 17:00:54
目前没有。服务模块封装了当前基于优先级/流行度的服务子集。此外,还计划对地理定位API进行一些改进,因此一直在等待。
从浏览器中使用此API非常容易,因为您只需将IP地址和订阅键附加到服务URL,并使用浏览器中的fetch API下载结果。下面是一个代码块:
interface IpToLocationResponse {
ipAddress: string;
countryRegion: IpToLocationCountry;
error: IpToLocationError;
}
interface IpToLocationCountry {
isoCode: string
}
interface IpToLocationError {
code: string;
message: string;
}
public ipToLocation(subscriptionKey, ipAddress): Promise<IpToLocationResponse> {
var request = `https://atlas.microsoft.com/geolocation/ip/json?subscription-key=${subscriptionKey}&api-version=1.0&ip=${ipAddress}`;
return fetch(request)
.then(r => {
return r.json();
});
}https://stackoverflow.com/questions/61069590
复制相似问题