generalized auth header

This commit is contained in:
Dalton committed 2018-12-12 20:28:10 -08:00
1 parent 803617304d
commit e564d2b94d
1 file changed
+9 -14
+9 -14
View File
@@ -228,9 +228,13 @@ async function loadJson(url, auth) {
let response;
if (auth) {
response = await fetch(url, auth);
sendToBotTestingChannel('imgur url:' + url);
sendToBotTestingChannel('imgur auth:' + JSON.stringify(auth));
response = await fetch(url, {
headers: {
Authorization: 'Client-ID ' + auth,
credentials: 'same-origin',
Accept: 'application/json'
}
});
} else {
response = await fetch(url);
}
@@ -254,18 +258,9 @@ async function asyncImageRequest(channelMessage) {
//collect all the json
let image_url_list = [];
let reddit_json = await loadJson("https://www.reddit.com/r/" + requested_item + "/.json?show=all&count=25&limit=100");
let imgur_json = await loadJson(
'https://api.imgur.com/3/gallery/r/' + requested_item + '/time/' + getRandomInt(1, 5),
{
headers: {
Authorization: 'Client-ID ' + auth.imgur,
credentials: 'same-origin',
Accept: 'application/json'
}
}
);
let imgur_json = await loadJson('https://api.imgur.com/3/gallery/r/' + requested_item + '/time/' + getRandomInt(1, 5), auth.imgur);
console.log('imgur_json -> ' + JSON.stringify(imgur_json));
//console.log('imgur_json -> ' + JSON.stringify(imgur_json));
// todo need to check config to see if it's a valid booruuuuu
//let redditbooru_json = await loadJson("https://" + requested_item + ".redditbooru.com/images/?limit=1000");