mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
wrap response in polling call
This commit is contained in:
parent
393623c4c0
commit
6ac9ba2741
@ -78,22 +78,29 @@ export default async function handler(req, res) {
|
|||||||
settled: false
|
settled: false
|
||||||
}, { ex: expiry || 86400 });
|
}, { ex: expiry || 86400 });
|
||||||
|
|
||||||
// Trigger the polling endpoint without waiting for it
|
// Trigger the polling endpoint
|
||||||
fetch(`${BACKEND_URL}/api/invoices/short-poll`, {
|
try {
|
||||||
|
await axios.get(`${BACKEND_URL}/api/invoices/short-poll`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': PLEBDEVS_API_KEY
|
'Authorization': PLEBDEVS_API_KEY
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
|
||||||
console.error('Error triggering polling:', error);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return response immediately
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
invoice,
|
invoice,
|
||||||
payment_hash: paymentHashHex,
|
payment_hash: paymentHashHex,
|
||||||
verify_url: verifyUrl
|
verify_url: verifyUrl
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error triggering polling:', error);
|
||||||
|
// return the response anyway, long running polling will be handled by the cron job
|
||||||
|
res.status(200).json({
|
||||||
|
invoice,
|
||||||
|
payment_hash: paymentHashHex,
|
||||||
|
verify_url: verifyUrl
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For non-zap requests, send response immediately
|
// For non-zap requests, send response immediately
|
||||||
|
Loading…
x
Reference in New Issue
Block a user