2018-04-15 02:51:02 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const util = require('util');
|
|
|
|
const config = require('config');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
function imgurImage(post) {
|
|
|
|
return fetch(`https://api.imgur.com/3/image/${post.host.id}`, {
|
|
|
|
headers: {
|
|
|
|
'Authorization': `Client-ID ${config.methods.imgur.clientId}`
|
|
|
|
}
|
|
|
|
}).then(res => res.json()).then(res => {
|
|
|
|
return {
|
|
|
|
album: null,
|
|
|
|
items: [{
|
|
|
|
id: res.data.id,
|
|
|
|
url: res.data.link,
|
|
|
|
title: res.data.title,
|
|
|
|
description: res.data.description,
|
|
|
|
type: res.data.type,
|
2018-04-16 21:46:39 +00:00
|
|
|
datetime: res.data.datetime * 1000,
|
2018-04-15 02:51:02 +00:00
|
|
|
original: res.data
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
}).catch(error => {
|
2018-04-17 22:18:04 +00:00
|
|
|
console.error(error);
|
2018-04-15 02:51:02 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = imgurImage;
|