Skip to content

Instantly share code, notes, and snippets.

@korrio
Created June 13, 2019 08:57
Show Gist options
  • Save korrio/191136690b24d5d8d611f4d7a5f19aa7 to your computer and use it in GitHub Desktop.
Save korrio/191136690b24d5d8d611f4d7a5f19aa7 to your computer and use it in GitHub Desktop.
stupid.fetch.js
const fetch = require("node-fetch");
async function getJson() {
return await fetch('https://mcot.aq1.co/api/sure.json')
.then(response => response.json())
.then(data => {
let arr = [];
console.log(data) // Prints result from `response.json()` in getRequest
data.output.forEach(function(v, i) {
let title = v.title;
let description = v.description;
let feature_url = mediaUrl + v.feature_url;
//let cover_vdo_url = mediaUrl + v.cover_video_url;
let tags = v.tags.map(function(v, i) {
return v.text;
});
let focus_tags = v.focus_tags.map(function(v, i) {
return v.text;
});
let categories = v.categories.map(function(v, i) {
return v.text;
});
let medias = v.medias.map(function(v, i) {
return {
url: mediaUrl + v.url,
thumbnailUrl: mediaUrl + v.thumbnailUrl };
});
let shortid = v.shortid;
let json = {
title,
description,
feature_url,
//cover_vdo_url,
tags,
focus_tags,
categories,
medias,
shortid
}
console.log(sureJson)
arr.push(json);
})
return arr;
})
.catch(error => console.error(error));
}
exports.create = {
Post:
getJson()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment