How do you know if a file exists

I want to check if the file exists when I jump to the url. How do I do that?

Hi @chuxinhao,

Is the file an asset in your Playcanvas project?

If that’s the case you can more simply do this (make sure your asset names are unique):

if('MyHtmlFile.html') !== null){

   // asset exists

If you are asking how to check if an external url exists, you need to make a GET request and check the result. Playcanvas provides an easy to use http requests class:

Thank you for your reply. I want to check whether the external URL exists.Use the Get

1 Like