Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 1.2 KB

File metadata and controls

57 lines (42 loc) · 1.2 KB

Get address from postal code using Web API and set

Get address from postal code using Web API and set.
Web APIを利用して郵便番号から住所を取得して設定します。

The following API is used. (Address in Japan)
下記のAPIを利用します。

Setting

Path Pattern

None

Insert Position

Bottom of issue form

Code

JavaScript

$(function() {

  // Note: Change the ID according to the custom field you want to target
  const zipcodeField = $('#issue_custom_field_values_1');
  const addressField = $('#issue_custom_field_values_2');

  zipcodeField.on('change', async () => {
    if (addressField.val() == '') {
      const res = await (await fetch('https://zipcloud.ibsnet.co.jp/api/search?zipcode=' + zipcodeField.val())).json();
      if (res.status == '200') {
        const result = res.results[0];
        addressField.val(result.address1 + result.address2 + result.address3);
      }
    }
  });
})

Result

result