Created
June 5, 2017 22:57
-
-
Save akirattii/ab9704c6502877b4e6f33c2405c7f099 to your computer and use it in GitHub Desktop.
郵便番号検索API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fetch address by zipcode | |
*/ | |
function fetchAddressByZipcode(zipcode, cb) { | |
let url = "http://zipcloud.ibsnet.co.jp/api/search?callback=?&zipcode=" + zipcode; | |
$.getJSON(url).done((data, status, jqXHR) => { | |
let result = data["results"][0]; | |
vm.prefecture = result["address1"]; | |
vm.city = result["address2"]; | |
vm.town = result["address3"]; | |
return cb && cb(status, data); | |
}); | |
} | |
fetchAddressByZipcode("1000001", (err, data) => { | |
console.log(data); | |
/* | |
{ | |
"message": null, | |
"results": [ | |
{ | |
"address1": "東京都", | |
"address2": "千代田区", | |
"address3": "千代田", | |
"kana1": "トウキョウト", | |
"kana2": "チヨダク", | |
"kana3": "チヨダ", | |
"prefcode": "13", | |
"zipcode": "1000001" | |
} | |
], | |
"status": 200 | |
} | |
*/ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
動作しないだけど