From 01fb0aedf5864b593118725af4ad0be262abc401 Mon Sep 17 00:00:00 2001 From: Eneko Nieto Date: Thu, 22 Jan 2026 19:47:29 +0100 Subject: [PATCH] feat: convert xml to utf-8 --- appwrite.config.json | 6 +++--- functions/aemet/src/main.ts | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/appwrite.config.json b/appwrite.config.json index 5cf6031..ad12df0 100644 --- a/appwrite.config.json +++ b/appwrite.config.json @@ -55,9 +55,9 @@ "timeout": 15, "enabled": true, "logging": true, - "entrypoint": "src/main.js", - "commands": "npm install", + "entrypoint": "dist/main.js", + "commands": "npm install && npm run build", "path": "functions/aemet" } ] -} \ No newline at end of file +} diff --git a/functions/aemet/src/main.ts b/functions/aemet/src/main.ts index 10a0a54..9991fc7 100644 --- a/functions/aemet/src/main.ts +++ b/functions/aemet/src/main.ts @@ -18,10 +18,13 @@ export default async ({ req, res, log, error }: any) => { throw new Error(`Error! status: ${response.status}`); } + const decoder = new TextDecoder('iso-8859-15'); + let xml = decoder.decode(await response.arrayBuffer()) + const parser = new XMLParser(); - let json = parser.parse(await response.text()); + let json = parser.parse(xml); log(json) - return res.json({sucess: false, data: json}) + return res.json({sucess: true, data: json}) } catch(err: any) { error("Error fetching forecast: " + err.message);