Checking result status rather than ok for imgur methods.

This commit is contained in:
ThePendulum 2018-04-28 17:07:16 +02:00
parent d9845bc596
commit 45182c07db
3 changed files with 5 additions and 4 deletions

View File

@ -47,9 +47,10 @@ users.forEach(username => {
submissions submissions
})); }));
}).then(({user, 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, user,
posts posts
})); }));

View File

@ -10,7 +10,7 @@ function imgurAlbum(post) {
'Authorization': `Client-ID ${config.methods.imgur.clientId}` 'Authorization': `Client-ID ${config.methods.imgur.clientId}`
} }
}).then(res => res.json()).then(res => { }).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}`); throw new Error(`Could not fetch info for imgur album '${post.host.id}': ${res.data.error}`);
} }

View File

@ -10,7 +10,7 @@ function imgurImage(post) {
'Authorization': `Client-ID ${config.methods.imgur.clientId}` 'Authorization': `Client-ID ${config.methods.imgur.clientId}`
} }
}).then(res => res.json()).then(res => { }).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}`); throw new Error(`Could not fetch info for imgur image '${post.host.id}': ${res.data.error}`);
} }