Search code examples
javascriptasynchronousrazoruwp

LaunchUriAsync throwing exception when used in JavaScript


I am trying to call LaunchUriAsync from a cshtml view using JavaScript code. Below is my code.

try {
    let appStatus = Windows.System.Launcher.LaunchUriAsync(new Windows.Foundation.Uri("https://www.google.com")).done(
        function (success) {
            console.log("launch complete");
            if (success) {
                console.log("launch success")
            } else {
                console.log("launch failed")
            }
        }, function (err) {
            console.log("launch error")
        });
}
catch (ex) {
    console.log("launch throws")
    console.log(JSON.stringify(ex))
}

I am getting the output "launch throws" but I am getting empty exception logged to console so not really understanding what is the exception that is thrown. Any idea why this might be throwing?


Solution

  • launchUriAsync with a lowercase l works:

    Windows.System.Launcher.launchUriAsync(new Windows.Foundation.Uri("https://www.google.com"))