mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Wrap promises with try blocks
This commit is contained in:
@@ -9,17 +9,21 @@ const exampleLnurlAuth = async () => {
|
||||
// ANCHOR: lnurl-auth
|
||||
// Endpoint can also be of the form:
|
||||
// keyauth://domain.com/auth?key=val
|
||||
const lnurlAuthUrl =
|
||||
'lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu'
|
||||
try {
|
||||
const lnurlAuthUrl =
|
||||
'lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu'
|
||||
|
||||
const input = await parseInput(lnurlAuthUrl)
|
||||
if (input.type === InputTypeVariant.LN_URL_AUTH) {
|
||||
const result = await lnurlAuth(input.data)
|
||||
if (result.type === LnUrlCallbackStatusVariant.OK) {
|
||||
console.log('Successfully authenticated')
|
||||
} else {
|
||||
console.log('Failed to authenticate')
|
||||
const input = await parseInput(lnurlAuthUrl)
|
||||
if (input.type === InputTypeVariant.LN_URL_AUTH) {
|
||||
const result = await lnurlAuth(input.data)
|
||||
if (result.type === LnUrlCallbackStatusVariant.OK) {
|
||||
console.log('Successfully authenticated')
|
||||
} else {
|
||||
console.log('Failed to authenticate')
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
// ANCHOR_END: lnurl-auth
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user