Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/YanAnghelp/home
No response
高德IP的API必须添加&ip=参数,否则输出空白,这是高德BUG。 以下是我对 src/api/index.js 改进的部分代码:
// 获取高德地理位置信息 export const getAdcode = async (key) => { const ip_response = await fetch('https://get-ip.xxxx.com/api'); const ip_data = await ip_response.json(); const userIp = ip_data.ip; const res = await fetch(https://restapi.amap.com/v3/ip?key=${key}&ip=${userIp}); return await res.json(); };
https://restapi.amap.com/v3/ip?key=${key}&ip=${userIp}
get-ip是个我随手写的获取用户ip的小项目,用next.js,兼容CORS,项目已经开源,随便用https://github.com/YanAnghelp/get-ip
The text was updated successfully, but these errors were encountered:
唉,不对,我弄错了。高德的IP解析API仅支持IPV4,但是API服务器支持IPV6这才是导致无法解析的元凶。但是部署在vercel上的服务仅支持IPV4,这才能正常获取到IPV4地址
Sorry, something went wrong.
到底还是高德的锅,哈哈
#370
No branches or pull requests
站点链接
https://github.com/YanAnghelp/home
问题描述
No response
补充信息
高德IP的API必须添加&ip=参数,否则输出空白,这是高德BUG。
以下是我对 src/api/index.js 改进的部分代码:
// 获取高德地理位置信息
export const getAdcode = async (key) => {
const ip_response = await fetch('https://get-ip.xxxx.com/api');
const ip_data = await ip_response.json();
const userIp = ip_data.ip;
const res = await fetch(
https://restapi.amap.com/v3/ip?key=${key}&ip=${userIp}
);return await res.json();
};
get-ip是个我随手写的获取用户ip的小项目,用next.js,兼容CORS,项目已经开源,随便用https://github.com/YanAnghelp/get-ip
The text was updated successfully, but these errors were encountered: