ripunzel/methods/imgurImage.js

31 lines
830 B
JavaScript

'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,
datetime: res.data.datetime * 1000,
original: res.data
}]
};
}).catch(error => {
console.error(error);
});
};
module.exports = imgurImage;