Type cast according to UniFi hotspot documentation

This commit is contained in:
Glenn de Haan
2026-01-04 11:41:13 +01:00
parent 72fcfd53c7
commit e0d1087da5

View File

@@ -22,9 +22,9 @@ module.exports = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Set base voucher data // Set base voucher data
const data = { const data = {
count: amount, count: typeof amount === "string" ? parseInt(amount): amount,
name: note, name: note,
timeLimitMinutes: type.expiration timeLimitMinutes: parseInt(type.expiration)
}; };
// Set voucher limit usage if limited // Set voucher limit usage if limited
@@ -34,17 +34,17 @@ module.exports = {
// Set data usage limit if limited // Set data usage limit if limited
if(typeof type.megabytes !== "undefined") { if(typeof type.megabytes !== "undefined") {
data.dataUsageLimitMBytes = type.megabytes; data.dataUsageLimitMBytes = parseInt(type.megabytes);
} }
// Set download speed limit if limited // Set download speed limit if limited
if(typeof type.download !== "undefined") { if(typeof type.download !== "undefined") {
data.rxRateLimitKbps = type.download; data.rxRateLimitKbps = parseInt(type.download);
} }
// Set upload speed limit if limited // Set upload speed limit if limited
if(typeof type.upload !== "undefined") { if(typeof type.upload !== "undefined") {
data.txRateLimitKbps = type.upload; data.txRateLimitKbps = parseInt(type.upload);
} }
fetch(`/hotspot/vouchers`, 'POST', {}, data).then((response) => { fetch(`/hotspot/vouchers`, 'POST', {}, data).then((response) => {