ripunzel/methods/imgurImage.js

32 lines
848 B
JavaScript
Raw Normal View History

'use strict';
const note = require('note-log');
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,
datetime: res.data.datetime,
original: res.data
}]
};
}).catch(error => {
note(error);
});
};
module.exports = imgurImage;