README
klogic-zip-code
郵便番号、もしくは住所から該当住所を検索するライブラリ。
目次
デモ
https://k-logic24.github.io/klogic-zip-code/
サポートブラウザ
IE以外のモダンブラウザで使用可能。
インストール
npm使用
npm install klogic-zip-code
yarn使用
yarn add klogic-zip-code
使用方法
初期化
// commonjs
const { KlogicZipCode } = require('klogic-zip-code')
// ES6
import { KlogicZipCode } from 'klogic-zip-code'
const klogicZipCode = new KlogicZipCode()
オプション
名前 | 型 | 説明 | デフォルト値 |
---|---|---|---|
limit | number | データ取得件数 | 50 |
is_hyphen | boolean | 取得郵便番号のハイフンの有無 | true |
import { KlogicZipCode } from 'klogic-zip-code'
const klogicZipCode = new KlogicZipCode({
limit: 50,
is_hyphen: true
})
郵便番号から検索
メソッド使用時、引数に以下のオブジェクトをとります。
名前 | 型 | 説明 | 必須 | デフォルト値 |
---|---|---|---|---|
zipcode | string | 郵便番号 | true | "" |
is_exact | boolean | 完全一致 | false |
完全一致
const klogicZipCode = new KlogicZipCode()
klogicZipCode.searchAddressFromZip({
zipcode: 'xxx-xxxx',
is_exact: true
})
.then(data => {
// do sccess
})
.catch(err => {
// do failture
})
前方一致
const klogicZipCode = new KlogicZipCode()
klogicZipCode.searchAddressFromZip({
zipcode: 'xxx',
})
.then(data => {
// do sccess
})
.catch(err => {
// do failture
})
住所から検索
メソッド使用時、引数に以下のオブジェクトをとります。
名前 | 型 | 説明 | 必須 | デフォルト値 |
---|---|---|---|---|
address | string | 住所 | true | "" |
is_exact | boolean | 完全一致 | false | |
is_left | boolean | 前方一致 | false |
完全一致
const klogicZipCode = new KlogicZipCode()
klogicZipCode.searchZipFromAddress({
address: 'xx県oo市△△町',
is_exact: true
})
.then(data => {
// do sccess
})
.catch(err => {
// do failture
})
前方一致
const klogicZipCode = new KlogicZipCode()
klogicZipCode.searchZipFromAddress({
address: 'xx県oo市',
is_left: true
})
.then(data => {
// do sccess
})
.catch(err => {
// do failture
})
部分一致
const klogicZipCode = new KlogicZipCode()
klogicZipCode.searchZipFromAddress({
address: 'oo市△△町',
})
.then(data => {
// do sccess
})
.catch(err => {
// do failture
})