feat: convert xml to utf-8
This commit is contained in:
@@ -55,9 +55,9 @@
|
|||||||
"timeout": 15,
|
"timeout": 15,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"logging": true,
|
"logging": true,
|
||||||
"entrypoint": "src/main.js",
|
"entrypoint": "dist/main.js",
|
||||||
"commands": "npm install",
|
"commands": "npm install && npm run build",
|
||||||
"path": "functions/aemet"
|
"path": "functions/aemet"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,13 @@ export default async ({ req, res, log, error }: any) => {
|
|||||||
throw new Error(`Error! status: ${response.status}`);
|
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();
|
const parser = new XMLParser();
|
||||||
let json = parser.parse(await response.text());
|
let json = parser.parse(xml);
|
||||||
log(json)
|
log(json)
|
||||||
return res.json({sucess: false, data: json})
|
return res.json({sucess: true, data: json})
|
||||||
|
|
||||||
} catch(err: any) {
|
} catch(err: any) {
|
||||||
error("Error fetching forecast: " + err.message);
|
error("Error fetching forecast: " + err.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user