(e)
| 2 | document.querySelector('body').addEventListener('click', deleteLocation) |
| 3 | |
| 4 | function getLocationInfo(e) { |
| 5 | const zip = document.querySelector('.input').value |
| 6 | console.log(zip); |
| 7 | |
| 8 | fetch(`https://api.postalpincode.in/pincode/${zip}`) |
| 9 | .then(response => { |
| 10 | console.log(response); |
| 11 | console.log(response.status); |
| 12 | return response.json() |
| 13 | }) |
| 14 | .then(data => { |
| 15 | console.log(data); |
| 16 | let output = ""; |
| 17 | if(data[0].PostOffice == null) { |
| 18 | console.log("Hello"); |
| 19 | showIcon("remove") |
| 20 | document.querySelector("#output").innerHTML = ` |
| 21 | <article class="message is-danger"> |
| 22 | <div class="message-body">Invalid Zipcode, please try again</div></article>` |
| 23 | } else { |
| 24 | showIcon('check') |
| 25 | data[0].PostOffice.forEach((post) => { |
| 26 | console.log(post); |
| 27 | output += ` |
| 28 | <article class="message is-secondary is-dark"> |
| 29 | <div class="message-header "> |
| 30 | <p><i class="fa fa-map-pin"></i> Location Info</p> |
| 31 | <button class="delete"></button> |
| 32 | </div> |
| 33 | <div class="message-body mbody"> |
| 34 | <ul> |
| 35 | <li><strong>Name : </strong>${post.Name}</li> |
| 36 | <li><strong>BranchType : </strong>${post.BranchType}</li> |
| 37 | <li><strong>DeliveryStatus : </strong>${post.DeliveryStatus}</li> |
| 38 | <li><strong>Circle : </strong>${post.Circle}</li> |
| 39 | <li><strong>District : </strong>${post.District}</li> |
| 40 | <li><strong>Division : </strong>${post.Division}</li> |
| 41 | <li><strong>Region : </strong>${post.Region}</li> |
| 42 | <li><strong>State : </strong>${post.State}</li> |
| 43 | <li><strong>Country : </strong>${post.Country}</li> |
| 44 | </ul> |
| 45 | </div> |
| 46 | </article> |
| 47 | ` |
| 48 | }) |
| 49 | document.querySelector('#output').innerHTML = output |
| 50 | } |
| 51 | }) |
| 52 | |
| 53 | e.preventDefault() |
| 54 | } |
| 55 | |
| 56 | function showIcon(icon) { |
| 57 | document.querySelector('.icon-remove').style.display = 'none' |
nothing calls this directly
no test coverage detected