Skip to content

Instantly share code, notes, and snippets.

@parasdaryanani
Last active March 16, 2022 13:34
Show Gist options
  • Save parasdaryanani/cb4764eed24d1c2f6d03ad85b52222da to your computer and use it in GitHub Desktop.
Save parasdaryanani/cb4764eed24d1c2f6d03ad85b52222da to your computer and use it in GitHub Desktop.
Get county from postcode
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