Created
June 7, 2024 12:15
-
-
Save Yummy-Yums/0dae0f93066b3bc012b8e1a3dd581072 to your computer and use it in GitHub Desktop.
Promise Workaround
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
export async function checkWhetherURLExists(url: URL) { | |
try{ | |
const response = await fetch(url.origin); | |
return response.status == 200 | |
} catch(error){ | |
return new Response("something went wronger") | |
} | |
} | |
export class UrlHandler implements URLInterface { | |
validateURLWell(url: string){ | |
const parsedURL = this.parseURL(url) as URL | |
const urlCheck = checkWhetherURLExists(parsedURL) | |
urlCheck | |
.then((value) => { | |
console.log("it's a" + value) | |
if(typeof value == "boolean" ){ | |
return true ? value == true : false | |
} else if ( value instanceof Response){ | |
} | |
}) | |
.then((value) => { | |
return value | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment