Skip to content

Instantly share code, notes, and snippets.

@jtomchak
Created March 22, 2022 15:35
Show Gist options
  • Save jtomchak/8f0f8898291335b8221bd668c02b249e to your computer and use it in GitHub Desktop.
Save jtomchak/8f0f8898291335b8221bd668c02b249e to your computer and use it in GitHub Desktop.
Upload JSON file to micro.blog
"use strict";
const querystring = require("querystring");
const axios = require("axios");
let jsonData = require("./strapiOutput.json");
async function upload() {
const articles = jsonData.map((category) => {
category.articles.map((article) => {
console.log(article.title);
axios.post(
"https://micro.blog/micropub",
querystring.stringify({
h: "entry",
name: article.title,
content: article.body,
published: article.published_at,
category: [category.Tag],
}),
{
headers: {
Authorization: "Bearer " + "<TOKEN_VALUE_HERE>",
"Content-Type": "multipart/form-data",
},
}
);
});
});
await Promise.all(articles).catch((err) => console.log(err));
}
upload();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment