Parse JSON on reception

This commit is contained in:
Jeroen Engels 2021-03-11 13:54:48 +01:00
parent 0ec6075098
commit e58d19290e

View File

@ -9,7 +9,7 @@ function get(url) {
data += chunk;
});
resp.on('end', () => {
resolve(data);
resolve(JSON.parse(data));
});
}).on("error", resolve);
})
@ -26,8 +26,8 @@ if (!packageName) {
async function downloadFiles() {
const [elmJson, docsJson] = await Promise.all([
get(`https://package.elm-lang.org/packages/${packageName}/latest/elm.json`).then(s => JSON.parse(s)),
get(`https://package.elm-lang.org/packages/${packageName}/latest/docs.json`).then(s => JSON.parse(s))
get(`https://package.elm-lang.org/packages/${packageName}/latest/elm.json`),
get(`https://package.elm-lang.org/packages/${packageName}/latest/docs.json`)
]);
return [elmJson, docsJson];
}