Last active
March 16, 2022 13:34
-
-
Save parasdaryanani/cb4764eed24d1c2f6d03ad85b52222da to your computer and use it in GitHub Desktop.
Get county from postcode
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
function findCounty(postcode) { | |
var response = UrlFetchApp.fetch('api.postcodes.io/postcodes/' + postcode); | |
var resJson = JSON.parse(response.getContentText()) | |
return resJson.result['admin_county']; | |
} | |
function findCountyAlt(postcode) { | |
var response = UrlFetchApp.fetch('api.postcodes.io/postcodes/' + postcode); | |
var resJson = JSON.parse(response.getContentText()) | |
return resJson.result['primary_care_trust']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment