added update config items functionality

This commit is contained in:
2024-02-18 12:04:14 +01:00
parent 5242d4a3af
commit 2e1d3f7026
7 changed files with 363 additions and 61 deletions

View File

@ -79,6 +79,34 @@ export default defineEventHandler(async (event) => {
}
}
}
if (event.path.startsWith("/api/updateConfigItem")) {
const body = await readBody(event)
// update the config item in the backend
try {
let res = await axiosInstance.put(`https://${serversideConfig.url}:${serversideConfig.port}/configItem`, body);
} catch (err) {
if (axios.isAxiosError(err)) {
const axiosError = err as AxiosError;
if (axiosError.response) {
// Axios error
console.error(axiosError.response.data.message);
errorMsg = axiosError.response.data.message;
} else if (axiosError.request) {
console.log(err)
// If error was caused by the request
console.error(axiosError.request);
} else {
// Other errors
console.error('Error', axiosError.message);
}
} else {
// No AxiosError
console.error('Error', err);
}
}
}
})
export { configItems, configItem, errorMsg };