Skip to content

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sefinek committed Jun 2, 2022
1 parent 6aa98ea commit 107bea9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ function getContent(url) {
return new Promise((resolve, reject) => {
get(url, res => {
if (res.statusCode !== 200) {
res.resume();
reject(`Request failed with status code ${res.statusCode}.`);
}

res.setEncoding('utf8');
let rawData = '';
res.on('data', chunk => {rawData += chunk;});
res.on('data', chunk => rawData = chunk);
res.on('end', () => {
try {
resolve(JSON.parse(rawData));
Expand Down

0 comments on commit 107bea9

Please sign in to comment.