Skip to content

Instantly share code, notes, and snippets.

@skeptrunedev
Last active December 4, 2023 07:29
Show Gist options
  • Save skeptrunedev/213989e3a44a459c7eca87c9b15a3a0a to your computer and use it in GitHub Desktop.
Save skeptrunedev/213989e3a44a459c7eca87c9b15a3a0a to your computer and use it in GitHub Desktop.
Test Arguflow Search With Stoicism Quotes
// alternative general quotes at https://raw.githubusercontent.com/JamesFT/Database-Quotes-JSON/master/quotes.json
// strongly recommend running the following with bun such that you do not have to import node-fetch
const quotes = JSON.parse(
await (
await fetch(
"https://gist.githubusercontent.com/miharekar/d57b58b017c457cd18062a1c36d82e02/raw/76df8f30010456dceafe7d5f39357242410fe403/quotes.json"
)
).text()
);
const apiUrl = "http://127.0.0.1:8090/api";
const apiKey = "API_KEY";
const createUrl = `${apiUrl}/card`;
for (const quote of quotes.quotes) {
// select 3 random words from the quote
const words = quote.text.split(" ");
const randomWords = [];
for (let i = 0; i < 3; i++) {
randomWords.push(words[Math.floor(Math.random() * words.length)]);
}
const requestBody = {
card_html: quote.text,
link: `https://${randomWords.join("")}.com}`,
tag_set: randomWords.join(","),
private: false,
metadata: {
author: quote.author,
},
};
const response = await fetch(createUrl, {
headers: {
"content-type": "application/json",
Authorization: apiKey,
},
body: JSON.stringify(requestBody),
method: "POST",
mode: "cors",
credentials: "include",
});
if (!response.ok) {
const errorText = await response.text();
console.log(errorText);
}
await new Promise((resolve) => setTimeout(resolve, 100));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment