From 1581e780b8d66e20b485b7293ead30c6e8a4bf43 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Wed, 11 Sep 2024 05:16:54 +0200 Subject: [PATCH] Checking result status rather than ok for imgur methods. --- src/app.js | 5 +++-- src/methods/imgurAlbum.js | 2 +- src/methods/imgurImage.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app.js b/src/app.js index 8136a42..9e641e2 100644 --- a/src/app.js +++ b/src/app.js @@ -47,9 +47,10 @@ users.forEach(username => { submissions })); }).then(({user, submissions}) => { - const posts = curateSubmissions(submissions, ignore).slice(0, limit); + const posts = curateSubmissions(submissions, ignore); + const limitedPosts = posts.slice(0, limit); - return fetchInfo(posts).then(info => ({ + return fetchInfo(limitedPosts).then(info => ({ user, posts })); diff --git a/src/methods/imgurAlbum.js b/src/methods/imgurAlbum.js index 5cd03f4..84e736a 100644 --- a/src/methods/imgurAlbum.js +++ b/src/methods/imgurAlbum.js @@ -10,7 +10,7 @@ function imgurAlbum(post) { 'Authorization': `Client-ID ${config.methods.imgur.clientId}` } }).then(res => res.json()).then(res => { - if(!res.ok) { + if(res.status !== 200) { throw new Error(`Could not fetch info for imgur album '${post.host.id}': ${res.data.error}`); } diff --git a/src/methods/imgurImage.js b/src/methods/imgurImage.js index 95978fe..d7222a3 100644 --- a/src/methods/imgurImage.js +++ b/src/methods/imgurImage.js @@ -10,7 +10,7 @@ function imgurImage(post) { 'Authorization': `Client-ID ${config.methods.imgur.clientId}` } }).then(res => res.json()).then(res => { - if(!res.ok) { + if(res.status !== 200) { throw new Error(`Could not fetch info for imgur image '${post.host.id}': ${res.data.error}`); }