fixed ttl return data parsing
This commit is contained in:
@@ -650,37 +650,25 @@
|
|||||||
fetch(
|
fetch(
|
||||||
"/cgi-bin/set_ttl?" + new URLSearchParams({ ttlvalue: ttlval })
|
"/cgi-bin/set_ttl?" + new URLSearchParams({ ttlvalue: ttlval })
|
||||||
)
|
)
|
||||||
.then((res) => res.text())
|
.then((res) => res.text()) // Use res.text() instead of res.json()
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
// Split the response into JSON and non-JSON parts
|
// Manually handle the response data
|
||||||
const parts = data.trim().split("\n\n");
|
console.log("Response from server:", data);
|
||||||
const nonJsonPart = parts[0];
|
// You can try to parse the JSON manually or handle the response as needed
|
||||||
const jsonPart = parts[1];
|
|
||||||
|
|
||||||
// Log the non-JSON part
|
|
||||||
console.log("Non-JSON response:", nonJsonPart);
|
|
||||||
|
|
||||||
// Parse the JSON part
|
|
||||||
try {
|
|
||||||
const jsonData = JSON.parse(jsonPart);
|
|
||||||
console.log("JSON response:", jsonData);
|
|
||||||
|
|
||||||
// Handle the JSON data as needed
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// Once TTL is updated, fetch the updated TTL data
|
// Once TTL is updated, fetch the updated TTL data
|
||||||
this.fetchTTL();
|
this.fetchTTL();
|
||||||
this.isLoading = false; // Set loading state back to false
|
this.isLoading = false; // Set loading state back to false
|
||||||
} catch (error) {
|
|
||||||
console.error("Error parsing JSON:", error);
|
|
||||||
this.isLoading = false; // Ensure loading state is properly handled in case of error
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Error updating TTL: ", error);
|
console.error("Error updating TTL: ", error);
|
||||||
this.isLoading = false; // Ensure loading state is properly handled in case of error
|
this.isLoading = false; // Ensure loading state is properly handled in case of error
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
init() {
|
||||||
|
this.fetchTTL();
|
||||||
|
this.fetchCurrentSettings();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user