I have a simple Google Apps Script that checks URLs, however, I would like to display something like "Not valid" for any non-200 status responses. Everything I try shows "#ERROR!" on the Google Sheet except for status 200 responses.
Here is my code:
function check_url(url) {
var response = UrlFetchApp.fetch(url)
if( response.getResponseCode() == 200 ) {
return true
} else if( response.getResponseCode() == 401 ) {
return "401"
} else {
return "Not Valid"
}
}
Any help is greatly appreciated as I am not very familiar with GA scripts or Javascript.
Thanks!