Skip to content

Commit 366f3d3

Browse files
Copilotnetmindz
andcommitted
Fetch fresh data from /json/info endpoint before reporting upgrade
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
1 parent 783634d commit 366f3d3

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

_codeql_detected_source_root

Lines changed: 0 additions & 1 deletion
This file was deleted.

wled00/data/index.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,17 +3387,20 @@ function showVersionUpgradePrompt(info, oldVersion, newVersion) {
33873387
function reportUpgradeEvent(info, oldVersion, newVersion) {
33883388
showToast('Reporting upgrade...');
33893389

3390-
// Prepare data to send (using info endpoint data)
3391-
// Send the entire info object as the backend expects
3392-
const upgradeData = Object.assign({}, info);
3393-
3394-
// Make AJAX call to postUpgradeEvent API
3395-
fetch('https://usage.wled.me/api/v1/usage/upgrade', {
3396-
method: 'POST',
3397-
headers: {
3398-
'Content-Type': 'application/json'
3399-
},
3400-
body: JSON.stringify(upgradeData)
3390+
// Fetch fresh data from /json/info endpoint as requested
3391+
fetch(getURL('/json/info'), {
3392+
method: 'get'
3393+
})
3394+
.then(res => res.json())
3395+
.then(infoData => {
3396+
// Make AJAX call to postUpgradeEvent API with fresh info data
3397+
return fetch('https://usage.wled.me/api/v1/usage/upgrade', {
3398+
method: 'POST',
3399+
headers: {
3400+
'Content-Type': 'application/json'
3401+
},
3402+
body: JSON.stringify(infoData)
3403+
});
34013404
})
34023405
.then(res => {
34033406
if (res.ok) {

0 commit comments

Comments
 (0)