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:
@@ -5,12 +5,16 @@ import {
|
||||
|
||||
const exampleSendSpontaneousPayment = async () => {
|
||||
// ANCHOR: send-spontaneous-payment
|
||||
const nodeId = '...'
|
||||
try {
|
||||
const nodeId = '...'
|
||||
|
||||
const sendPaymentResponse = await sendSpontaneousPayment({
|
||||
nodeId,
|
||||
amountMsat: 3000000
|
||||
})
|
||||
const sendPaymentResponse = await sendSpontaneousPayment({
|
||||
nodeId,
|
||||
amountMsat: 3000000
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
}
|
||||
|
||||
@@ -24,15 +28,19 @@ const stringToBytes = (str: string): number[] => {
|
||||
|
||||
const exampleSendSpontaneousPaymentWithTlvs = async () => {
|
||||
// ANCHOR: send-spontaneous-payment-with-tlvs
|
||||
const nodeId = '...'
|
||||
const extraTlvs: TlvEntry[] = [
|
||||
{ fieldNumber: 34349334, value: stringToBytes('Hello world!') }
|
||||
]
|
||||
try {
|
||||
const nodeId = '...'
|
||||
const extraTlvs: TlvEntry[] = [
|
||||
{ fieldNumber: 34349334, value: stringToBytes('Hello world!') }
|
||||
]
|
||||
|
||||
const sendPaymentResponse = await sendSpontaneousPayment({
|
||||
nodeId,
|
||||
amountMsat: 3000000,
|
||||
extraTlvs
|
||||
})
|
||||
const sendPaymentResponse = await sendSpontaneousPayment({
|
||||
nodeId,
|
||||
amountMsat: 3000000,
|
||||
extraTlvs
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
// ANCHOR_END: send-spontaneous-payment-with-tlvs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user