4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vue.js で グローバルipアドレスを取得する ウルテク

Last updated at Posted at 2019-04-07

こんな感じでipアドレスを取得できるがね。
素晴らしいがね。


axios.post('https://ipinfo.io/').then(e => {
    console.log(e.data.ip);
    console.log("成功");
        }).catch((error) => {
    console.log("エラー");
});

日本語対応ブラウザのみ

上記の ipinfo は関係なく使える。
日本語に対応したブラウザのみ対応させたい場合。


if((navigator.browserLanguage || navigator.language || navigator.userLanguage).substr(0,2) === 'ja') {
    console.log("多分日本語ブラウザ");
}

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?